using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
string[] scores={89,80,98,56,60,91,93,85};
string[] names={吴松,钱东宇,伏晨,陈陆,周蕊,林日鹏,何昆,关欣};
int max=scores[0];
for(int i=0;i<8;i++)
if(max<scores[i])
max=scores[i];
{
Console.WriteLine(最高分数是"+names[i]+",分数是"+max");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
string[] scores={89,80,98,56,60,91,93,85};
string[] names={吴松,钱东宇,伏晨,陈陆,周蕊,林日鹏,何昆,关欣};
int max=scores[0];
for(int i=0;i<8;i++)
if(max<scores[i])
max=scores[i];
{
Console.WriteLine(最高分数是"+names[i]+",分数是"+max");
}
}
}
}
if选择语句里少“{}”大括号
scores的数组不是整数类型的吗?你用的是string类
int [] scores={89,80,98,56,60,91,93,85};
string[] names={"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
int max=scores[0];
int index = 0;
for (int i = 0; i < 8; i++)
{
if (max < scores[i])
{
max = scores[i];
index = i;
}
}
Console.WriteLine("最高分数是" + names[index] + ",分数是" + max);
你的“最高分数是”你是不是缺了前面的 ”?这里用的是字符串