12.101. Učitati dva niza A i B od po M članova. Formirati treći niz C od M članova prema izrazu: C[i]=A[i]+B[i]
Opis programa:
Listing programa:
PROGRAM p10111010;
CONST
n = 5;
VAR
i : INTEGER;
A, B, C : ARRAY [1..n] OF INTEGER;
BEGIN
WRITELN('Suma clanova niza');
FOR i := 1 TO n DO {ulaz niza A}
BEGIN
WRITE('A[', i, '] --> ');
READLN(A[i]);
END;
FOR i := 1 TO n DO {ulaz niza B}
BEGIN
WRITE('B[', i, '] --> ');
READLN(B[i]);
END;
FOR i:=1 TO n DO {novi niza C}
C[i] := A[i] + B[i];
FOR i := 1 TO n DO {izlaz niza C}
WRITELN('C[',i,'] = ',C[i]);
READLN;
END.
Index
|
|