#include <iostream> #include <stdio.h> using namespace std;
int main(){ int y; cin>>y; y=y%12; switch (y){ case 4:{cout<<"Mouse"; break;} case 5:{cout<<"Bull";break;} case 6:{cout<<"Tiger";break;} case 7:{cout<<"Rabbit";break;} case 8:{cout<<"Dragon";break;} case 9:{cout<<"Snake";break;} case 10:{cout<<"Horse";break;} case 11:{cout<<"Goat";break;} case 0:{cout<<"Monkey";break;} case 1:{cout<<"Cock";break;} case 2:{cout<<"Dog";break;} case 3:{cout<<"Pig";break;} } cin.get(); cin.get(); return 0; }
Программа:
Pascal:
№2)
var
m: array[1..10] of integer;
begin
m[1]:=4; m[2]:=8; m[3]:=7; m[4]:=2; m[5]:=1; m[6]:=8; m[7]:=1; m[8]:=5; m[9]:=6; m[10]:=8;
for var i := 1 to 10 do
if m[i] = m.max then m[i]:= 0;
writeln(m);
end.
№3)
const n = 10;
var
a: array[1..n] of integer;
i, k, tmp: integer;
begin
for i := 1 to n do a[i] := random(0, 1);
writeln('Массив: ', a);
for i := 1 to n - 1 do
for k := 1 to n - i do
if a[k] > a[k + 1] then begin
tmp := a[k];
a[k] := a[k + 1];
a[k + 1] := tmp;
end;
writeln(a);
end.
№5)
const n = 10;
var
a: array[1..n] of integer;
a1, a2: array[1..n div 2] of integer;
i, k, tmp: integer;
begin
for i := 1 to n do a[i] := random(-10, 10);
writeln('Исходный массив: ',a);
for i := 1 to n div 2 do a1[i] := a[i];
for i := (n div 2 + 1) to n do a2[i - n div 2] := a[i];
for i := 1 to n div 2 - 1 do
for k := 1 to n div 2 - i do
if a1[k] > a1[k + 1] then begin
tmp := a1[k];
a1[k] := a1[k + 1];
a1[k + 1] := tmp;
end;
for i := 1 to n div 2 - 1 do
for k := 1 to n div 2 - i do
if a2[k] < a2[k + 1] then begin
tmp := a2[k];
a2[k] := a2[k + 1];
a2[k + 1] := tmp;
end;
for i := 1 to n do
if i <= 5 then a[i] := a1[i]
else a[i] := a2[i - n div 2];
writeln('Выходной массив: ', a);
end.
#include <stdio.h>
using namespace std;
int main(){
int y;
cin>>y;
y=y%12;
switch (y){
case 4:{cout<<"Mouse"; break;}
case 5:{cout<<"Bull";break;}
case 6:{cout<<"Tiger";break;}
case 7:{cout<<"Rabbit";break;}
case 8:{cout<<"Dragon";break;}
case 9:{cout<<"Snake";break;}
case 10:{cout<<"Horse";break;}
case 11:{cout<<"Goat";break;}
case 0:{cout<<"Monkey";break;}
case 1:{cout<<"Cock";break;}
case 2:{cout<<"Dog";break;}
case 3:{cout<<"Pig";break;}
}
cin.get();
cin.get();
return 0;
}