看不懂這個,有沒有大佬指點(diǎn)一下
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[]{ "吳松", "錢東宇", "伏晨", "陳陸", "周蕊", "林日鵬", "何昆", "關(guān)欣", };
? ? ? ? ? ? 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);
? ? ? ? }
? ? }
}
2023-01-27
string[] name = new string[] { "吳松", "錢東宇", "伏晨", "陳陸", "周蕊", "林日鵬", "何昆", "關(guān)欣" };
? ? ? ? ? ? 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("分?jǐn)?shù)最高的是" + Name + ",分?jǐn)?shù)是" + max);