Переписать код с Pascal на C# - C# (191301)
Формулировка задачи:
Надо срочно переписать код. Голова что-то вообще не варит.
var mas: array[1..4] of integer;
i,maxc:integer;
Procedure Max(var x,y:integer);
begin
if x<y then
x:=y;
end;
begin
for i:=1 to 4 do
begin
write('Введите число: ');
readln(mas[i]);
end;
maxc:=mas[1];
for i:=2 to 4 do
Max(maxc,mas[i]);
write('max= ',maxc);
readln;
end.Решение задачи: «Переписать код с Pascal на C#»
textual
Листинг программы
using System;
public class myprog
{
int mas[1,4];
int i, maxc;
public static void Max(int x,y)
{
if(x>y) x=y;
}
public static void Main()
{
for(i=0;i<4;i++)
{
Console.WriteLine("Введите число: ");
mas[i]=Console.Read();
}
maxc=mas[0];
for(i=1;i<4;i++) Max(maxc,mas[i]);
Console.WriteLine("max={0} ",maxc);
Console.ReadKey();
}
}