then max:=i; for i:=1 to n do begin at:=a[m,i]; a[m,i]:=a[max,i]; a[max,i]:=at end; for i:=1 to n do begin for j:=1 to n do write(a[i,j]:4); writeln end end.
13) program pasc;
var a:array[1..200] of real; i,n:integer; d,r1,R2:real; begin readln(n); for i:=1 to n do begin readln(a[2*i-1]); readln(a[2*i]); end; d:=sqrt(sqr(a[1])+sqr(a[2])) r1:=d; R2:=d; for i:=1 to n do begin d:=sqrt(sqr(a[2*i-1])+sqr(a[2*i])); if dR2 then R2:=d end; writeln('r=',r1); writeln('R=',R2) end.
14) program pasc;
var a:array[1..100,1..100] of integer;
i,j,n:integer; begin readln(n); for i:=1 to n div 2 do for j:=i to n do
begin a[i,j]:=0; if ((j>=i) and (j<=(n-i+1))) and (i<=(n div 2)+1)
then begin a[i,j]:=1; a[n-i+1,j]:=1; end;
end; if n mod 2=1 then a[n div 2+1,j div 2+1]:=1; for i:=1 to n do
begin for j:=1 to n do write(a[i,j]:2); writeln end; readln end.
15) program mas;
var a:array[1..100] of integer;
i,n,k:integer;
begin readln(n); for i:=1 to n do begin readln(a[i]); end; i:=1; while i
16) program Min;
type Mass=array [1..100] of integer;
function MinK(X:Mass;k:integer):integer;
var Result,R:integer;
begin
Result:=X[k]; if k>1 then
begin
R:=MinK(X,k-1); if Result>R then Result:=R end;
MinK:=Result end; ar X:Mass; n,i:integer; begin readln(n);
for i:=1 to n do begin readln(X[i]) end; writeln('Min(X)=',MinK(X,n))
end.
17) program gauss;
uses crt;
const nn=10;
var a:array [1..nn,1..nn] of double;
x,b:array [1..nn] of double;
n,i,j,k:integer;d:double; begin clrscr; readln(n); for i:=1 to n do
begin for j:=1 to n do read(a[i,j]); end; for i:=1 to n do read (b[i]);
for i:=1 to n-1 do begin for k:=i+1 to n do begin
d:=a[k,i]/a[i,i]; for j:=i+1 to n do a[k,j]:=a[k,j]-a[i,j]*d;
b[k]:=b[k]-b[i]*d; end; end; for i:=n downto 1 do
begin for j:=i+1 to n do b[i]:=b[i]-a[i,j]*x[j]; x[i]:=b[i]/a[i,i]; end; writeln; for i:=1 to n do writeln('X[',i:2,']=',x[i]:1:5); end.
18) program res; uses CRT;
const N=5;
var A : array [ 1..N, 1..N ] of integer = ((1, 1, 1, 1, 1), (1, 2, 3, 4, 5), (1, 2, 3, 4, 5),(2, 2, 2, 2, 2),(1, 3, 3, 7, 5)); var i, j, str, sum, max : integer; b: boolean; BEGIN
ClrScr; max:= -1; str:= -1; for i:= 1 to N do begin sum:= 0; b:= false; for j:= 1 to N do begin sum:= sum + abs(A[i,j]); if not odd (A[i,j]) then b:= true; end; if (not b) and (sum>max) then begin max:= sum; str:= i; end; end; WriteLn('< OK >'); ReadKey; END.
19) program N1;
var N:integer;
function KOL(N:integer):integer;
begin if N>9 then KOL:=KOL(N mod 10)+KOL(N div 10) else KOL:=1;
end;BEGIN ReadLn(N); WriteLn(KOL(N)); ReadLn; END.
20) program pasc;
var b,a,n,k: integer;
begin readln(n); k:=n; a:=k mod 10; repeat b:=k mod 10; k:=k div 10 until k div 10 =0; b:=k mod 10; writeln(a,n div 10 div 10 mod 10,n div 10 mod 10,b) end.
21) PROGRAM pasc;
TYPE massiv=array [1..50] of integer;
var a:massiv; n,i:integer; begin readln(n);
i:=1; while n>=2 do begin a[i]:= n mod 2; i:=i+1;
n:= n div 2; end; i:=i-1; write(n); while I < >0 do
begin write(' ',a[i]); i:=i-1; end; writeln end.
22) program 3;
uses crt;
var i , s, n, dni, a : Integer; begin ClrScr;
ReadLn(n); ReadLn(dni); s := 0; a := 0; if dni > n then begin
TextColor(Red); GotoXY(15,5); GotoXY(15,6); end else begin for i := 1 to dni do begin if a mod n = 0 then begin
s := n div 2; n := n - s; end else begin
a := n - 1; s := a div 2; n := n - s + 1 end end;
end; WriteLn; Write('Press Enter'); ReadLn end.
23) program 4;
uses crt;
var vklad, prozent, a : Real; i, let, b : Integer; begin
ClrScr; ReadLn(vklad); ReadLn(let); ReadLn(prozent);
for i := 1 to let do begin a := (vklad / 100) * prozent;
vklad := vklad + a end; WriteLn( vklad:10:2); WriteLn;
WriteLn('Press Enter'); ReadLn end.
24) program 7;
uses crt;
var i, a, b, n : Integer; begin ClrScr; ReadLn(n);
a := 0; i := 0; b := 0; repeat a := a + 2; Inc(i);
b := a * (a + 2) until b >= n; WriteLn( i, i + 1); WriteLn;
Write('Press Enter'); ReadLnend.
25) program Funct;
uses crt;
Var D,A,B,x,y,C:real;
function P(n:real):real;
begin P:= exp(1/3*ln(n)); end; begin
clrscr; write('x = '); readln(x); write('y = '); readln(y);
A:= P(x)+ P(y); writeln('A = ',A); readln; end.
26) Program Vera;
Uses crt;
var x,y,z,s,r:real; n,i,j:integer; b:boolean;
begin Clrscr;
write('enter x: '); readln(x); writeln(x); write('enter n: '); readln(n); writeln(n);
s := 0; b := false; if (not odd(n)) then n := n + 1; i := 1; while i <= n do begin y := x; z := 1; j := 1; while j < i do
begin y := y*x; j := j + 1; z := z*j; end;
if b = true then s := s-y/z else s := s+y/z; b := not b; i := i + 2;
r := sin(s); end; writeln(r); readln; end.
27) program piram;
uses crt;
var j,i:integer;
begin
clrscr;
for i:=1 to 25 do begin gotoxy(40-i,i); for j:=2 to 2*i do
write('*'); end; end.
28 ) Program Cylinder;
Uses Crt; Var R, H, V, S: Real;
BEGIN ClrScr;
ReadLn(H); ReadLn(R);
V := Pi * R * R * H; S := 2 * Pi * R * H; WriteLn;
WriteLn( S : 5 : 2); ReadLn END.
29) Program Points;
Uses Crt;
Var xA, yA, xB, yB, xC, yC, DistA, DistB, DistC : Real;
BEGIN ClrScr; Write('x = '); ReadLn(xA);
Write('y = '); ReadLn(yA); Write('x = '); ReadLn(xB);
Write('y = '); ReadLn(yB); Write('x = '); ReadLn(xC);
Write('y = '); ReadLn(yC); DistA := sqrt(sqr(xA) + sqr(yA));
DistB := sqrt(sqr(xB) + sqr(yB)); DistC := sqrt(sqr(xC) + sqr(yC));
If ( DistA < DistB) and (DistA < DistC) then WriteLn( a)
else If (DistB < DistC) then WriteLn( B) else WriteLn( C);
ReadLn END.
30) Program Quadratic;
Uses Crt; Var a, b, c : Real;
Discr : Real; x1, x2 : Real; Test, NTest : Integer;
EGIN ClrScr;
ReadLn(NTest); For Test := 1 to NTest do begin
ReadLn(a, b, c); begin Discr := b*b - 4*a*c;
If Discr > 0 then begin x1:=(-b + Sqrt(Discr)) / (2*a); x2:=(-b - Sqrt(Discr)) / (2*a); WriteLn('x1=' , x1:6:2 , '; x2=' , x2:6:2) end else if Discr = 0 then begin x1 := -b/(2*a); WriteLn(`x1=', x1:6:2, ' x2=', x1:6:2) end else WriteLn('natija yo`q'); end; WriteLn end; ReadLn END.
31) Program SummaFib;
Uses Crt;
Var M, F0, F1, F2, S : Integer;
BEGIN
ClrScr;
ReadLn(M); F0:=1; F1:=1; F2:=2; S:=4;
Write(M, ' : ', F0:4, F1:4); While F2<=M do
begin F0:=F1; F1:=F2; Write(F1 : 4); F2:=F0+F1; S : =S+F2;
end; S:=S - F2; WriteLn; WriteLn( S ); ReadLn END.
32) program thir;
uses crt;
var a, b : LongInt;
begin clrscr; a:=1;
writeln; while a < > 0 do
begin readln(a);
while a > = 10 do begin
a : =a div 10; end;
b : =b*10+a; end; write(b div 10); readln; end.
Hatolar kodlari va ular to`g`risida ma`lumotlar