Kód:
program p1;
uses crt;
var A,Moc: integer;
begin;
clrscr;
randomize;
repeat
A:=random(50);
Moc:=sqr(A);
writeln(A,' - ',Moc);
until A=0;
readln;
end.
Príklad 2:Kód:
program p2;
uses crt;
var I,N,S:integer;
A:array[1..10000] of integer;
P:real;
begin
clrscr;
randomize;
writeln('Zadaj kolko cisel mam vygenerovat, minimalna hodnota, ktoru mozes zadat je 2');
readln(N);
writeln('Nahodne cisla su: ');
For I:=1 to N do
begin
A[I]:=random(10)+1;
write (A[I]:5);
end;
writeln;
For I:=1 to N do
S:=S+A[I];
P:=S/N;
writeln ('Priemer nahodnych cisel je ',P:3:2);
readln;
end.
Príklad 3:Kód:
program p3;
uses crt;
var Max,Min,I:integer; A:array[1..10] of integer;
begin
clrscr;
randomize;
Max:=0;
Min:=101;
writeln('Nahodne cisla su: ');
For I:=1 to 10 do
begin
A[I]:=random(100);
write(A[I]:5);
end;
writeln;
For I:=1 to 10 do
begin
If A[I]>Max then Max:=A[I];
If A[I]<Min then Min:=A[I];
end;
writeln ('Najvecsie cislo je ',Max,' a najmensie cislo je ',Min);
readln;
end.
Priklad 4:Kód:
program p4;
uses crt;
var I,P,A:integer;
begin
clrscr;
randomize;
repeat
A:=random(100);
write(A:5);
P:=P+1;
until A=0;
writeln;
writeln('Pocet cisel ay kym nevygenerovalo nulu je ',P-1,' .');
readln;
end.
Priklad 5:Kód:
program p5;
uses crt;
var I,P,S,A:integer;
begin
clrscr;
randomize;
repeat
A:=random(20);
write(A:5);
P:=P+1;
S:=S+A;
until (S=1000) or (S>1000);
writeln;
writeln('Sucet vybranych cisel je ',S,' a ich pocet je ',P,' .');
readln;
end.
Priklad 6:Kód:
program p6;
uses crt;
var I,S,N:integer;
P:real;
A:array[1..10000] of integer;
begin
clrscr;
randomize;
writeln('Kolko chces nahodnych cisel?');
readln(N);
writeln('Nahodne cisla su:');
For I:=1 to N do
begin
A[I]:=random(100)+1;
write(A[I]:5);
S:=S+A[I];
end;
P:=S/N;
writeln;
writeln('Sucet vybranych cisel je ',S,' a ich priemer je ',P:3:2,' .');
readln;
end.
Príklad 7:Kód:
program p7;
uses crt;
var I,S,S1,P,P1:integer;
Priemer1,Priemer2:real;
A:array[1..100] of integer;
begin
clrscr;
randomize;
writeln('Nahodnych 100 cisel:');
For I:=1 to 100 do
begin
A[I]:=random(100);
write(A[I]:5);
end;
For I:=1 to 100 do
begin
If (A[I]>20) and (A[I]<50) then
begin
P:=P+1;
S:=S+A[I];
end
else
begin
P1:=P1+1;
S1:=S1+A[I];
end;
end;
Priemer1:=S/P;
Priemer2:=S1/P;
writeln;
writeln('Sucet cisel z intervalu 20-50 je ',S,' a ich priemer je ',Priemer1:3:2,' a ich pocet je ',P,' .');
writeln('Sucet cisel mimo intervalu 20-50 je ',S1,' a ich priemer je ',Priemer2:3:2,' a ich pocet je ',P1,' .');
readln;
end.
Priklad 10:Kód:
program p10;
uses crt;
var A,B,C,Sodmo:integer;X1,X2,X3:real;
begin
clrscr;
writeln('Zadaj cleny(koeficienty) a,b,c z kvadratickej rovnice.');
readln (A,B,C);
clrscr;
writeln(A,'x2 + ',B,'x + ',C, '= 0');
Sodmo:=sqr(B)-(4*A*C);
If Sodmo<0 then writeln ('Kvadraticka rovnica nema riesenie.')
else
begin
If Sodmo=0 then
begin
X3:=-B/(2*A);
writeln('Rovnica ma dvojnasobny koren: {',X3:3:2,'}.');
end
else
begin
X1:=(-B+(sqrt(Sodmo)))/(2*A);
X2:=(-B-(sqrt(Sodmo)))/(2*A);
writeln('Korene rovnice su: {',X1:3:2,', ',X2:3:2,'}.');
end;
end;
readln;
end.
zadanie
http://www.pixhost.org/show/208/318175_ ... _00000.jpg
mozte mi to prosim vas skontrolovat?