主题:日历问题
爱丽斯LING
[专家分:560] 发布于 2007-08-14 09:52:00
若知道某年1月1日是星期N,那么按要求输出这个年的第K个月的日历.
回复列表 (共3个回复)
沙发
我的电脑 [专家分:990] 发布于 2007-08-14 10:10:00
CLS
INPUT "nian:"; m
10 INPUT "N="; n: IF n < 1 OR n > 7 OR n <> n \ 1 THEN 10
20 INPUT "K="; k: IF k < 1 OR n > 12 OR k <> k \ 1 THEN 20
DIM a(12): s = 0
FOR i = 1 TO 12
READ a(i)
NEXT i
DATA 31,28,31,30,31,30,31,31,30,31,30,31
IF m / 4 = m \ 4 AND m / 100 <> m \ 100 THEN a(2) = 29
FOR i = 1 TO k - 1
s = s + a(i)
NEXT i
s = s MOD 7: q = 0
30 FOR i = n TO 7
q = q + 1: IF q = s THEN a = i + 1: GOTO 40
NEXT i
IF q < s THEN n = 1: GOTO 30
40 PRINT TAB(25); " R";
FOR i = 1 TO 6
PRINT TAB(i * 5 + 25); i;
NEXT i: PRINT
s = 0
IF a > 6 THEN a = a - 7
50 FOR i = a TO 6
p = p + 1: PRINT TAB(i * 5 + 25); p;
IF p = a(k) THEN END
NEXT i
IF p < a(k) THEN a = 0: GOTO 50
板凳
QB小猪 [专家分:1200] 发布于 2007-08-14 10:12:00
CLS
FOR i = 1 TO 26
x$ = x$ + CHR$(64 + i)
NEXT i
10 LOCATE 7, 37: PRINT LEFT$(x$, 8);
FOR i = 1 TO 5:
LOCATE 7 + i, 37: PRINT MID$(x$, 27 - i, 1);
LOCATE 7 + i, 44: PRINT MID$(x$, 8 + i, 1);
NEXT i
FOR i = 1 TO 8
LOCATE 13, 36 + i: PRINT MID$(x$, 22 - i, 1);
NEXT i
FOR t = 1 TO 10000
NEXT t
x$ = RIGHT$(x$, 25) + LEFT$(x$, 1)
v$ = INKEY$
IF v$ <> "" THEN END ELSE GOTO 10
3 楼
小精灵1号 [专家分:1040] 发布于 2007-08-14 10:14:00
CLS
INPUT N$
DIM A(12)
Y = VAL(MID$(N$, 1, 4)): M = VAL(MID$(N$, 5, 2))
IF Y MOD 400 = 0 OR Y MOD 4 = 0 AND Y MOD 100 <> 0 THEN Q = 1
IF Y > 2008 THEN R = (Y - 2008 + 3) \ 4 ELSE R = (2008 - Y) \ 4
P = ABS(2008 - Y) - R
IF Y > 2008 THEN S = (2 + 2 * R + P) MOD 7 ELSE S = (2 - 2 * R - P) MOD 7 + 7
FOR I = 1 TO M - 1
READ A(I)
IF I = 2 AND Q = 1 THEN A(I) = 29
S = S + A(I)
NEXT I
S = S MOD 7: READ A(I)
PRINT " SUN MOD TUE WED THU FRI SAT"
PRINT TAB(S * 4 + 1);
FOR I = 1 TO 7 - S: PRINT USING "####"; I; : NEXT I: PRINT
FOR J = I TO A(M): K = K + 1: PRINT USING "####"; J;
IF K MOD 7 = 0 THEN PRINT
NEXT J
END
DATA 31,28,31,30,31,30,31,31,30,31,30,31
我来回复