Introduce two arrays with different numbers of elements. Find how many elements one array is larger than another.
Let’s introduce the following designations: a – an array of n elements; a [i] – values of elements of array a; b – an array of k elements; b [i] – values of elements of array b; c and d – the number of elements of the arrays a and b, respectively, which will be counted during the program execution. We will use the loop operator with the for parameter. Then a program in the Pascal ABC programming language may look like this:
program zadaca1;
uses crt;
const n = 2; const k = 4;
var i, c, d: integer;
a: array [1..n] of integer;
b: array [1..k] of integer;
begin
c: = 0; d: = 0;
for i: = 1 to n do begin
writeln (‘vvedite znachenie a [i]:’);
readln (a [i]);
c: = c + 1;
end;
for i: = 1 to n do
write (a [i], ”);
writeln;
writeln (‘c =’, c);
for i: = 1 to k do begin
writeln (‘vvedite znachenie b [i]:’);
readln (b [i]);
d: = d + 1;
end;
for i: = 1 to k do
write (b [i], ”);
writeln;
writeln (‘d =’, d);
if c> d then writeln (‘massiv a bolshe masiva b na’, c-d)
else writeln (‘massiv b bolshe masiva a na’, d-c);
end.