weixin_慕沐4393982
2022-10-18 22:04
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
int[] num = new int[] { 89, 90, 98, 56, 60, 91, 83, 85 };
string []name = new string[]{ "吴松", "钱东宇", "伏晨", "陈陆", "周蕊", "林日鹏", "何昆", "关欣", };
int max = num[0];
string name1 = name[0];
foreach(int x in num)
{
if(max<num[0])
{
max = num[x];
name1 = name[x];
}
}
Console.WriteLine("成绩最好的是{0},他是{1}", max, name1);
}
}
}
string[] name = new string[] { "吴松", "钱东宇", "伏晨", "陈陆", "周蕊", "林日鹏", "何昆", "关欣" };
int[] score = new int[] { 89, 90, 98, 56, 60, 91, 93, 85 };
int max = score[0];
string Name = name[0];
for (int i = 0; i < score.Length; i++)
{
if (score[i] > max)
{
max = score[i];
Name = name[i];
continue;
}
else
{
continue;
}
}
Console.WriteLine("分数最高的是" + Name + ",分数是" + max);
C#开发轻松入门
254118 学习 · 1459 问题
相似问题