Misol: Massivning eng katta elementini va uning nomerini toping A = (a1, a2 , ..., aN ) .
Turbo Pascal
Program MaxElem;
Uses Crt;
Type Mas = Array [1..20] of Real;
Var A : Mas;
i, N : Integer;
k : Integer;
Amax : Real;
BEGIN
SlrScr;
Write(' N ni kirit= ');
ReadLn(N);
For i := 1 to N do { massiv elementlarini kiritish }
begin
Write('A [ ', i, ' ] = '); ReadLn(A[i])
end;
Amax := A[1]; k:=1; {eng katta elementni qidirish}
For i := 2 to N do
If A[i] > Amax then
begin
Amax := A[i]; k := i
end;
WriteLn; WriteLn(‘eng katta element' , k , '-');
WriteLn('uning qiymati', Amax : 5 : 1); ReadLn
END.
Mustaqil ishlash uchun topshiriqlar
3.1. [Pascal | C | Basic] A(N, M)matritsa berilgan. Uning eng katta elementi va qaysi ustun va satrga tegishli.
3.2. [Pascal | C | Basic] A(N, M) matritsaning har bir satrining musbat elementlari o’rta arifmetigini toping.
3.3. [Pascal | C | Basic] A(N, M)matritsa berilgan.Uning barcha elementlari o’rta arifmetigidan katta elementlarini chiqaring.
3.4. [Pascal | C | Basic] Butun sonli A(N, M) matritsa berilgan. Juft elementlari yig’indisini toping.
3.5. [Pascal | C | Basic] A(N, M) matritsa berilgan. A massivning har bir satrdagi musbat elementlarini Xj vektorga oluvchi dastur tuzing.
3.6. [Pascal | C | Basic] A(N, M) matritsa berilgan. Uning katta va kichik elementlari o’rninianiqlang.
[Pascal | C | Basic] (n,n ) matritsani quyidagi ko’rinishlarda hosil qiling.
Do'stlaringiz bilan baham: |