請問這那錯了
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string[] name = { "吳松", "錢東宇", "伏晨", "陳陸", "周蕊", "林日鵬", "何昆", "關(guān)欣" };
? ? ? ? ? ? int[] score = { 89, 90, 98, 56, 60, 91, 93, 85 };??
? ? ? ? ? ? int max=score[0];
? ? ? ? ? ? for(int i=0;i<score.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(score[i]<score[i+1])
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? max=score[i+1];
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }Console.WriteLine("分?jǐn)?shù)最高的是{0},分?jǐn)?shù)是{1}",name[max],score[max]);?
? ? ? ? }
? ? }
}
2020-08-20
? ? ? ? ? ? string[,]? sor=new string[,]
? ? ? ? ? ? {{"吳松","89"},{"錢東宇","90"},{"伏晨","98"},{"陳陸","56"},{"周蕊","60"},{"林日鵬","91"},{"何昆","93"},{"關(guān)欣","85"}? ? ? ? ? ? };
? ? ? ? ? ? //Console.WriteLine(sor.GetLength(0));
? ? ? ? ? ? int Max = 0;
? ? ? ? ? ? string Name="";
? ? ? ? ? ? for (int i = 0; i < sor.GetLength(0)-1; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (int.Parse(sor[i, 1]) > Max)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Max = int.Parse(sor[i, 1]);
? ? ? ? ? ? ? ? ? ? Name = sor[i, 0];
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine("分?jǐn)?shù)最高的是" + Name + ",分?jǐn)?shù)是" + Max);
2020-08-12
你的max的值獲取的應(yīng)該是i的值,而不是score[i]
2020-07-23
數(shù)組越界