Конвертировать с Pascal на C# - C# (183267)
Формулировка задачи:
Где/кто может конвертировать этот код с Pascal на C#?
Var a: array[1..100000] of integer; n, i, j, max, prmax: integer; begin read(n); for i:=1 to n do read(a[i]); max:=a[1]; for i:=2 to n do if a[i] >= max then begin write(max, ' '); prmax:=max; max:=a[i] end else if a[i] > prmax then begin write(a[i], ' '); prmax:=a[i] end else write(prmax, ' '); end.
Решение задачи: «Конвертировать с Pascal на C#»
textual
Листинг программы
int[] a = new int[100000];
int i, j, max, prmax = 0;
int n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
a[i] = int.Parse(Console.ReadLine());
max =a[1];
for (i = 2; i <= n; i++)
if (a[i] >= max)
{
Console.WriteLine(max + " ");
prmax = max;
max = a[i];
}
else
{
if (a[i] > prmax)
{
Console.WriteLine(a[i] + " ");
prmax = a[i];
}
else
Console.WriteLine(prmax + " ");
}