c#把For循环替换成while 循环
发布网友
发布时间:2023-09-21 15:50
我来回答
共1个回答
热心网友
时间:2023-09-22 04:09
//while循环
int j = 0;
while (j < num.Length)
{
int max = -1;
int index = -1;
int i = 0;
while (i < num.Length)
{
if (num[i] > max)
{
max = num[i];
index = i;
}
i++;
}
Console.WriteLine(max);
num[index] = -1;
j++;
}
Console.ReadKey();