1) const n=10; var a:array[1..n] of integer; i,min,s:integer; begin for i:=1 to n do begin a[i]:=random(81)+10; write(a[i]:4); end; writeln; min:=a[1]; for i:=1 to n do begin if a[i]<min then min:=a[i]; s:=s+a[i]; end; writeln('min = ',min); writeln('s = ',s); end.
Пример: 54 58 67 78 58 79 54 78 44 60 min = 44 s = 630
2) const n=9; m=6; var a:array[1..n,1..m] of integer; i,j:integer; begin for i:=1 to n do for j:=1 to m do a[i,j]:=i; for i:=1 to n do begin for j:=1 to m do write(a[i,j]); writeln; end; end.
Int[] arr = new int[] { 3, 2, 1, 5, 6 }; int min = arr[0]; int min_ind = 0; for(int i=1;i<arr.Length;i++) { if (arr[i] < min) { min = arr[i]; min_ind = i; } } for (var i = min_ind+1; i < arr.Length; i++) arr[i] = 0; for (var i =0; i < arr.Length; i++) Console.Write(arr[i]+" "); Console.ReadKey();
const n=10;
var a:array[1..n] of integer;
i,min,s:integer;
begin
for i:=1 to n do
begin
a[i]:=random(81)+10;
write(a[i]:4);
end;
writeln;
min:=a[1];
for i:=1 to n do
begin
if a[i]<min then min:=a[i];
s:=s+a[i];
end;
writeln('min = ',min);
writeln('s = ',s);
end.
Пример:
54 58 67 78 58 79 54 78 44 60
min = 44
s = 630
2)
const n=9; m=6;
var a:array[1..n,1..m] of integer;
i,j:integer;
begin
for i:=1 to n do
for j:=1 to m do a[i,j]:=i;
for i:=1 to n do
begin
for j:=1 to m do write(a[i,j]);
writeln;
end;
end.
Результат:
111111
222222
333333
444444
555555
666666
777777
888888
999999
int min = arr[0];
int min_ind = 0;
for(int i=1;i<arr.Length;i++)
{ if (arr[i] < min)
{
min = arr[i];
min_ind = i;
}
}
for (var i = min_ind+1; i < arr.Length; i++)
arr[i] = 0;
for (var i =0; i < arr.Length; i++)
Console.Write(arr[i]+" ");
Console.ReadKey();