int temp;
string str = Console.ReadLine();
string[] strArray = str.Split(' ');
int[] num = new int[strArray.Length];
for (int i = 0; i < strArray.Length; i++)
num[i] = Convert.ToInt32(strArray[i]);
int min = num[0];
int index=0;
for (int j = 1; j < num.Length; j++)
{
if (num[j] < min)
{
index = j;
min = num[j];
}
}
temp = num[0];
num[0] = num[index];
num[index] = temp;
for (int k = 0; k < strArray.Length; k++)
Console.WriteLine(num[k]);
17,输入n(n<100)个数,找出其中最小的数,将它与最前面的数交换后输出这些数
最新推荐文章于 2024-07-05 15:44:55 发布