int main() { int D = 0, M; cout <<"M = ",cin >> M; if (M>1) D+=31; if (M>2) D+=28; if (M>3) D+=31; if (M>4) D+=30; if (M>5) D+=31; if (M>6) D+=30; if (M>7) D+=31; if (M>8) D+=31; if (M>9) D+=30; if (M>10) D+=31; if (M>11) D+=30; D = D % 7; if (D == 0) D = 7; if (M==1||M==3||M==5||M==7||M==8||M==10||M==12) M = 32; else if (M==4||M==6||M==9||M==11) M = 31; else M = 29; for(int i = 1; i < D; i++) cout<<" "; cout<<" "; for(int i = D; i < 8; i++) cout <<i-D+1<<" "; int i = 9-D; while(i < M) { cout <<'\n'; for(int j = 0; j < 7&&i < M; j++) { if (i < 10) cout<<' '; cout << i++<<" "; } } return 0; }
CLS RANDOMIZE TIMER INPUT "N = ", N DIM D%(N) PRINT "D("; N; "):"; K = 0 FOR i = 1 TO N D%(i) = RND * (2 * N + 1) - N PRINT " "; D%(i); NEXT i PRINT INPUT "T = ", T FOR i = 1 TO N IF D%(i) = T THEN K = K + 1 END IF NEXT i PRINT "K = "; K END
2)
CLS RANDOMIZE TIMER DIM D%(14), C%(14) PRINT "D(14):"; K = 0 FOR i = 1 TO 14 D%(i) = RND * 41 - 20 PRINT " "; D%(i); IF D%(i) < 7 THEN K = K + 1 C%(K) = D%(i) END IF NEXT i PRINT PRINT "C("; K; "):"; FOR i = 1 TO K PRINT " "; C%(i); NEXT i END
using namespace std;
int main()
{
int D = 0, M;
cout <<"M = ",cin >> M;
if (M>1) D+=31;
if (M>2) D+=28;
if (M>3) D+=31;
if (M>4) D+=30;
if (M>5) D+=31;
if (M>6) D+=30;
if (M>7) D+=31;
if (M>8) D+=31;
if (M>9) D+=30;
if (M>10) D+=31;
if (M>11) D+=30;
D = D % 7;
if (D == 0) D = 7;
if (M==1||M==3||M==5||M==7||M==8||M==10||M==12) M = 32;
else if (M==4||M==6||M==9||M==11) M = 31;
else M = 29;
for(int i = 1; i < D; i++)
cout<<" ";
cout<<" ";
for(int i = D; i < 8; i++)
cout <<i-D+1<<" ";
int i = 9-D;
while(i < M)
{
cout <<'\n';
for(int j = 0; j < 7&&i < M; j++)
{
if (i < 10) cout<<' ';
cout << i++<<" ";
}
}
return 0;
}
CLS
RANDOMIZE TIMER
INPUT "N = ", N
DIM D%(N)
PRINT "D("; N; "):";
K = 0
FOR i = 1 TO N
D%(i) = RND * (2 * N + 1) - N
PRINT " "; D%(i);
NEXT i
PRINT
INPUT "T = ", T
FOR i = 1 TO N
IF D%(i) = T THEN
K = K + 1
END IF
NEXT i
PRINT "K = "; K
END
2)
CLS
RANDOMIZE TIMER
DIM D%(14), C%(14)
PRINT "D(14):";
K = 0
FOR i = 1 TO 14
D%(i) = RND * 41 - 20
PRINT " "; D%(i);
IF D%(i) < 7 THEN
K = K + 1
C%(K) = D%(i)
END IF
NEXT i
PRINT
PRINT "C("; K; "):";
FOR i = 1 TO K
PRINT " "; C%(i);
NEXT i
END