Считайте рост претендента в команду случайным числом из диапазона от 150 до 200 см,а число претендентов n=50. сделать программу на языке паскаля ,.оценка за четверть решается
procedure nod( var dv,tr,pt,dv1,tr1,pt1,dv2,tr2,pt2 :real; ); var a:array[1..6] of real; i : integer; begin dv1:=100; tr1:=100; pt1:=100; for i:= low(a) to high (a) do begin readln(a[i]); repeat if( (a[i] mod 2) =0) then begin a[i]:=a[i]/2; dv:=dv+1; end else if( ( a[i] mod 3)=0) then begin a[i]:=a[i]/3; tr:=tr+1; end else if ( ( a[i] mod 5)=0) then begin a[i]:=a[i]/5; pt:=pt+1; end;
untill(a=1); if dvif trif ptdv:=0; tr:=0; pt:=0; end; if dv1>0 then dv2:=dv1*2 else dv2:=1; if tr1>0 then tr2:=tr1*3 else tr2:=1; if pt1>0 then pt2:=pt1*5 else pt2:=1; nod:=dv2*tr2*pt2; writeln(nod); end; begin nod( dv,tr,pt,dv1,tr1,pt1,dv2,tr2,pt2 ); end.
Задача №1 //PascalABC.NET (версия 3.1, сборка 1196 от 09.03.2016) Var n, i: integer; Begin writeln ('Введите число'); readln(n); writeln('Делители числа:'); for i := 1 to n div 2 do if (n mod i) = 0 then begin write(i,' '); end; End.
Задача №2 (алгоритм не очень шустрый, но работает и понятный) //PascalABC.NET (версия 3.1, сборка 1196 от 09.03.2016) var a, b, x, y, nod: integer;
begin writeln('Введите a,b'); readln(a, b); x := a;y := b; while x <> y do if x > y then x := x - y else y := y - x; nod := x; writeln('NOD(', a, ',', b, ')=', nod); end.
using std::cout;
using std::cin;
using std::endl;
#include <cstdlib>
using std::rand;
using std::srand;
#include <ctime>
using std::time;int main()
{
srand(time(0));
int counter = 0;
int growth; for(int i = 0; i < 50; i++)
{
if((growth = rand() % 151 + 150) >= 170)
{
counter++;
}
cout << growth << ' ';
}
cout << endl << endl; cout << counter << " pupil";
cout << (counter != 1 ? "s" : "") << endl; // Если будет только 1 ученик,
//то больше ничего не печатать
//иначе - допечатать букву "s" cin.get();
return 0;