求指出錯誤,提示上說temp1有問題?
namespace projGetMaxScore
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
?????????? string[] name = {"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關欣"};
??????????? int[] score= {89,90,98,56,60,91,93};
??????????? int temp = score[0];
??????????? string temp1 = name[0];
??????????? for (int i = 1;i < 7;i++)
??????????? {
????????????? if(score[i+1] > temp)
???????????????? {
???????????????????? temp = score[i+1];
???????????????????? temp1 = name[i+1];
???????????????? }
??????????? }
??????????? {
??????????? Console.WriteLine("分數(shù)最高的是{0},分數(shù)是{1}","temp1",temp) ;
??????????? }
??????? }
??? }
}
2018-08-27
多謝大神指點,已解決
2018-08-20
錯誤1:score數(shù)組長度和name數(shù)組長度不一樣。
錯誤2:for循環(huán)中,既然循環(huán)里面用的索引是i+1,那么i初值應該等于0,即for (int i = 0; i < 7; i++)。
錯誤3:最后輸出最高分數(shù)時,temp1不應該加雙引號,加了雙引號,temp1就是字符串了,就不代表最高分數(shù)的人的名字了。