慕九州5455903
2018-07-05 18:42
namespace ConsoleApp11
{
class Program
{
static void Main(string[] args)
{
string[] names = new string[8] { "吴松", "钱东宇", "伏晨", "陈陆", "周蕊", "林日鹏", "何昆", "关欣" };
int[] scores = new int[8] { 89, 90, 98, 56, 60, 91, 93, 85 };
int x = 0;
for (x=0;x<8;x++ )
{
if (scores[x] > scores[0])
{
scores[0] =scores[x];
}
}
int max = scores[0];
Console.Write("分数最高的是" + names[x] + "分数是" + max );
}
}
}
字符串name为空
改成这样
string[] names = new string[8] { "吴松", "钱东宇", "伏晨", "陈陆", "周蕊", "林日鹏", "何昆", "关欣" };
int[] scores = new int[8] { 89, 90, 98, 56, 60, 91, 93, 85 };
string name = null;
int x = 0;
for (x=0;x<8;x++ )
{
if (scores[x] > scores[0])
{
scores[0] =scores[x];
name=names[x];
}
}
int max = scores[0];
Console.Write("分数最高的是{0},分数是{1}",name,max );
第三行是什么意思
C#开发轻松入门
254118 学习 · 1459 问题
相似问题