LET MODE=0 SELECT CASE MODE CASE 0 INPUT PROMPT "西暦 年、月、日 ": Y, M, N !' 1900<=Y<=2100 1<=M<=12 1<=N<=31 INPUT PROMPT "何日後=":Z LET L=NISSUU(Y,M,N)+Z LET YY=YEAR(L) LET MM=MONTH(L) LET DD=DAY(L) PRINT Y;"年";M;"月";N;"日(";WEEK$(Y,M,N);"曜日)" IF Z>0 THEN PRINT Z;"日後は" ELSE PRINT -Z;"日前は" PRINT YY;"年";MM;"月";DD;"日 ";WEEK$(YY,MM,DD);"曜日です" CASE 1 INPUT PROMPT "(1)西暦 年、月、日 ": Y1, M1, N1 INPUT PROMPT "(2)西暦 年、月、日 ": Y2, M2, N2 PRINT Y1;"年";M1;"月";N1;"日(";WEEK$(Y1,M1,N1);"曜日)から" PRINT Y2;"年";M2;"月";N2;"日(";WEEK$(Y2,M2,N2);"曜日)までの" PRINT "日数は";NISSUU(Y2,M2,N2)-NISSUU(Y1,M1,N1);"日です" END SELECT END
EXTERNAL FUNCTION NISSUU(Y,M,N) DIM D(12), DD(12) FOR I=1 TO 12 READ D(I) NEXT I DATA 0,31,59,90,120,151,181,212,243,273,304,334 FOR I=1 TO 12 READ DD(I) NEXT I DATA 31,28,31,30,31,30,31,31,30,31,30,31 LET YL = Y - 1 LET Z = 365 * YL + D(M) + N + INT(YL / 4) + INT(YL / 400) - INT(YL / 100) IF MOD(Y , 4) = 0 THEN IF MOD(Y , 100) <> 0 THEN IF M > 2 THEN LET Z = Z + 1 END IF END IF END IF IF MOD(Y , 400) = 0 THEN IF M > 2 THEN LET Z = Z + 1 END IF END IF LET NISSUU=Z END FUNCTION
EXTERNAL FUNCTION YEAR(ZZ) LET YA = 1900 !'1900年から LET YB = 2100 !'2100年まで DO LET YY = INT((YA + YB) / 2) LET YL = YY - 1 LET Z = 365 * YL + INT(YL / 4) + INT(YL / 400) - INT(YL / 100) + 1 IF ZZ - Z >= 0 AND ZZ - Z <= 365 THEN EXIT DO IF Z - ZZ < 0 THEN LET YA = YY ELSE LET YB = YY IF YA + 1 = YB THEN LET YA = YB LOOP UNTIL YA=YB LET YEAR=YY END FUNCTION EXTERNAL FUNCTION MONTH(ZZ) DIM D(12), DD(12) FOR I=1 TO 12 READ D(I) NEXT I DATA 0,31,59,90,120,151,181,212,243,273,304,334 FOR I=1 TO 12 READ DD(I) NEXT I DATA 31,28,31,30,31,30,31,31,30,31,30,31 LET YY=YEAR(ZZ) LET YL = YY - 1 LET Z = 365 * YL + INT(YL / 4) + INT(YL / 400) - INT(YL / 100) + 1 FOR MM = 1 TO 12 IF FLAG = 0 THEN IF MOD(YY , 4) = 0 AND MOD(YY , 100) <> 0 THEN LET DD(2) = 29 IF MM > 2 THEN LET Z = Z + 1 LET FLAG = 1 END IF END IF IF MOD(YY , 400) = 0 THEN LET DD(2) = 29 IF MM > 2 THEN LET Z = Z + 1 LET FLAG = 1 END IF END IF END IF IF ZZ - (Z + D(MM)) < DD(MM) THEN LET MONTH=MM EXIT FUNCTION END IF NEXT MM STOP !' ERROR END FUNCTION
|