各位大佬看,這樣寫怎么樣
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,93,85 };
? ? ? ? ? ? string[] name = new string[] { "1", "2", "3", "4", "5", "6", "7", "8" };
? ? ? ? ? ? int x = 0;
? ? ? ? ? ? int max = num[0];
? ? ? ? ? ? for (int i=0;i<name.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (num[i] > max)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? max = num[i];
? ? ? ? ? ? ? ? ? ? x++;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine("最好分姓名" + name[x] + "分?jǐn)?shù)是" + max);
? ? ? ? }
? ? }
}
2020-10-06
代碼有問題,x++使用不對(duì),不能用自加來確定x的位置。