string[] name = new string[5];//姓名数组
int[] num = new int[5];//分数数组
for (int i = 0; i < name.Length; i++)
{
Console.Write("请输入第" + (i + 1) + "位学生的姓名:");
name[i] = Console.ReadLine();
Console.Write("请输入第" + (i + 1) + "位学生的分数:");
num[i] = int.Parse(Console.ReadLine());
}
int max = num[0];
int ID = 0;
for (int i = 1; i < num.Length; i++)
{
if(num[i]>max)
{
max = num[i];
ID = i;
}
}
Console.WriteLine("学生中成绩最好的是" + max+"分,是第"+(ID+1)+"名学生,名字是"+ );
string[] name = new string[3];//姓名数组
int[] num = new int[3];//分数数组
for (int i = 0; i < name.Length; i++)
{
Console.Write("请输入第" + (i + 1) + "位学生的姓名:");
name[i] = Console.ReadLine();
Console.Write("请输入第" + (i + 1) + "位学生的分数:");
num[i] = int.Parse(Console.ReadLine());
}
int max = num[0];
int ID =0;
for (int i = 1; i < num.Length; i++)
{
if (num[i] > max)
{
max = num[i];
ID = i;
}
}
Console.WriteLine("学生中成绩最好的是{0}分,是第{1}名同学,名字是{2}", max, ID + 1, name[ID]);