уточнять на каком языке программирования нужно написать задачки. Я же напишу на С++. Алгоритм везде будет один и тот же.
1 задача
int x1 = 0;
int x2 = 0;
int x3 = 0;
int x4 = 0;
int x5 = 0;
cin >> x1;
cin >> x2;
cin >> x3;
cin >> x4;
cin >> x5;
double sr = 0.0;
sr = (x1+x2+x3+x4+x5)/5;
Или же можно сделать по проще
int x = 0;
int sum = 0;
double sr = 0.0;
for(int i = 0; i<5; i++){
cin >> x;
sum = sum +x;
}
sr = sum/5;
2 Задача
int number = 5;
for(int i = 2; i<20; i=i+2){
number = number + i;
}
1) program exec;
var a:array[1..20] of integer;
var p,i:integer;
begin
randomize;
for i:=1 to 20 do begin
a[i]:=random(50);
writeln (a[i]);
if (a[i] mod 2<>0) then p:=p+1;
end;
if (p>0) then writeln ('Присутствуют нечётные элементы')
else writeln ('Не присутствуют нечётные элементы');
end.
2) program exec;
var a:array[1..20] of integer;
var p,i:integer;
begin
randomize;
for i:=1 to 20 do begin
a[i]:=random(50);
writeln (a[i]);
if (a[i] mod 2=0) then a[i]:=a[i]+1
else a[i]:=a[i]*2;
end;
writeln ('---'); // разделение двух массивов
for i:=1 to 20 do writeln (a[i]);
end.
#include <cstdlib>
#include <iostream>
using namespace std;
int NOD( int a, int b)
{
int c=1;
int d;
if(a>b)
d=b;
else
d=a;
for(int j=1;j<=d;j++)
{
if(a%j==0 && b%j==0)
c=j;
}
return c;
}
int main()
{
int A,B,C;
cout<<"Введите А"<<endl;
cin>>A;
cout<<"Введите В"<<endl;
cin>>B;
cout<<"Введите С"<<endl;
cin>>C;
cout<<"НОД("<<A<<","<<B<<","<<C<<")="<<NOD(NOD(A,B),C)<<endl;
system("PAUSE");
return 0;
}
(Код написан на С++.)