//C# first problem using System; class Programm { static void Main() { int n=int.Parse(Console.ReadLine()); int[] a=new int [n]; for (int i=0;i<n;i++) { a[i]=i; Console.Write(a[i] + " "); } } }
//C# second problem using System; class Programm { static void Main() { int n=int.Parse(Console.ReadLine()); int[] a=new int [n]; int ma=0,mi=0,ma_p=0,mi_p=0; for (int i=0;i<n;i++) { a[i]=int.Parse(Console.ReadLine); } ma=a[0];mi=a[0];ma_p=0;mi_p=0; for (int i=0;i<n;i++) { if (ma<a[i]){ma=a[i];ma_p=i;} if (mi>a[i]){mi=a[i];mi_p=i;} } ma=a[ma_p]; a[ma_p]=a[mi_p]; a[mi_p]=ma; for (int i=0;i<n;i++){Console.Write(a[i] + " ");} } }
Const m=4; n=6; var a:array[1..m,1..n] of integer; i,j,max,jmax,min,jmin,t:integer; begin Randomize; writeln('Исходный массив:'); for i:=1 to m do begin for j:=1 to n do begin a[i,j]:=random(100); write(a[i,j]:4); end; writeln; end; max:=a[1,1]; jmax:=1; min:=a[1,1]; jmin:=1; for i:=1 to m do for j:=1 to n do begin if a[i,j]>max then begin max:=a[i,j]; jmax:=j; end; if a[i,j]<min then begin min:=a[i,j]; jmin:=j; end; end; writeln('max = ',max,' jmax = ',jmax); writeln('min = ',min,' jmin = ',jmin); for i:=1 to m do begin t:=a[i,jmax]; a[i,jmax]:=a[i,jmin]; a[i,jmin]:=t; end; writeln('Полученный массив:'); for i:=1 to m do begin for j:=1 to n do write(a[i,j]:4); writeln; end; end.