C#编写一个程序,对输入的四个正数,求出其中最大和最小的

来源:百度知道 编辑:UC知道 时间:2024/05/26 17:36:32

using System;

class GetMaxMin (
static void Main() {
double x,max,min;
int i = 1;
while (i<=4) {
Console.WriteLine("input x"+i);
x=double.parse(Console.ReadLine());
if (x<=0) {
Console.WriteLine("wrong!");
continue;
}
if (i == 1) {
max = x;
min = x;
} else if (x>max) {
max = x;
} else if (x<min) {
min = x;
}
i += 1;
}
Console.WriteLine("max:"+max+"min:"+min);
}
)