1) const n=10; var a:array[1..n] of integer; i,min,s:integer; begin for i:=1 to n do begin a[i]:=random(81)+10; write(a[i]:4); end; writeln; min:=a[1]; for i:=1 to n do begin if a[i]<min then min:=a[i]; s:=s+a[i]; end; writeln('min = ',min); writeln('s = ',s); end.
Пример: 54 58 67 78 58 79 54 78 44 60 min = 44 s = 630
2) const n=9; m=6; var a:array[1..n,1..m] of integer; i,j:integer; begin for i:=1 to n do for j:=1 to m do a[i,j]:=i; for i:=1 to n do begin for j:=1 to m do write(a[i,j]); writeln; end; end.
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; }
const n=10;
var a:array[1..n] of integer;
i,min,s:integer;
begin
for i:=1 to n do
begin
a[i]:=random(81)+10;
write(a[i]:4);
end;
writeln;
min:=a[1];
for i:=1 to n do
begin
if a[i]<min then min:=a[i];
s:=s+a[i];
end;
writeln('min = ',min);
writeln('s = ',s);
end.
Пример:
54 58 67 78 58 79 54 78 44 60
min = 44
s = 630
2)
const n=9; m=6;
var a:array[1..n,1..m] of integer;
i,j:integer;
begin
for i:=1 to n do
for j:=1 to m do a[i,j]:=i;
for i:=1 to n do
begin
for j:=1 to m do write(a[i,j]);
writeln;
end;
end.
Результат:
111111
222222
333333
444444
555555
666666
777777
888888
999999
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;
}