18张耀
2020-03-05 17:58
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
string[] name = new string[] { "吴松", "钱东宇", "伏晨", "陈陆", "周蕊", "林日鹏", "何昆", "关欣" };
int[] a = new int[] {89,90,98,56,60,91,93,85 };
int max;
max = a[0];
int sy = 0;
for(int i=1;i<a.Length;i++)
{
if (a[i] > max)
{
max = a[i];
sy = i;
}
}
Console.Write("分数最高的是" +name[sy]+","+"分数是"+max);
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
int max;
string[] name = new string[]{"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
int[] num = new int[]{89,90,98,56,60,91,93,85};
max=num[0];
string k =name[0];
for(int i=1;i<num.Length;i++)
{
if(num[i]>max)
{
max=num[i];
k=name[i];
}
}
Console.Write("分数最高的是{0},分数是{1},",k,max);
}
}
}
?,看来不是我一个人是这个思路,?
你的代码没错,不对是因为名字和分数之间的,是中文的,你的是英文?
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
string[,] chengji=new string[,]{
{"吴松","89"},{"钱东宇","90"},
{"伏晨","98"},{"陈陆","56"},
{"周蕊","60"},{"林日鹏","91"},
{"何昆","93"},{"关欣","85"}
};
string[] zuigao=new string[2];
for(int x=0; x<chengji.GetLongLength(0);x++){
if(zuigao[0]!=null && Convert.ToInt32(zuigao[1])>Convert.ToInt32(chengji[x,1])) continue;
else{
zuigao[0]=chengji[x,0];
zuigao[1]=chengji[x,1];
}
}
Console.WriteLine("分数最高的是{0},分数是{1}",zuigao[0],zuigao[1]);
}
}
}
代码确实没问题,我写的也对就是在这上面不对,你的i从0开始比较规范,改一改
C#开发轻松入门
254117 学习 · 1459 问题
相似问题