qq_艾多比_五色鸟动漫_0
2018-09-12 13:19
namespace test
{
class Program
{
static void Main(string[] args)
{
string[] name = { "吴松", "钱东宇", "伏晨", "陈陆", "周蕊", "林日鹏", "何昆", "关欣" };
int[]score = { 89, 90, 98, 56, 60, 91, 93, 85 };
int t = 0;
string r = "";
for (int i = 0; i < score.Length; i++)
{
if (score[i] > t)
t = score[i];
r = name[i];
}
Console.WriteLine("分数最高的是-" + r + "," );
Console.WriteLine("分数是-" + t);
}
}
}
max 不是关键字,用到max 是因为要查找最高分啊
代码供参考
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
string[]names={"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
int[]score={89,90,98,56,60,91,93,88};
int max=0;
int n=0;
for(int i=0;i<score.Length;i++)
{
if(score[i]>max)
{
max=score[i];
}
else
{
continue;
}
n=i;
}
Console.WriteLine("分数最高的是{0},分数是{1}",names[n],score[n]);
}
}
}
C#开发轻松入门
254118 学习 · 1459 问题
相似问题