qq_慕后端9396858
2020-08-07 16:55
namespace projAboveAvg
{
class Program
{
static void Main(string[] args)
{
string[,] couple = new string{ {"景珍","90"},{"林惠阳","65"},{"成蓉","88"},{"洪南昌","70"},{"龙玉民","46"},{"单江开","81"},{"田武山","100"},{"王三明","68"} };
int sum=0;
for(int i=0; i<couple.GetLongLength(0); i++)
{
sum += couple[i,1];
}
int avg = sum/8;
Console.Write("平均分是{0},高于平均分的有:",avg);
for(int i=0; i<couple.GetLongLength(0); i++)
{
if(couple[i,1]>avg)
Console.WriteLine(couple[i,0]);
}
}
}
}
4、int类型无法接收string类型,就是你的sum
5、检查代码中是否有中文标点符号
6、int avg = sum/8最好改成 sum/couple.Length
1、couple.GetLongLength(0)改成couple.Length;参见https://docs.microsoft.com/zh-cn/dotnet/api/system.array.getlonglength?view=netcore-3.1
2、第二个打印改成Write
3、""里面的标点符号改成中文的标点符号
C#开发轻松入门
254118 学习 · 1459 问题
相似问题