關(guān)于本節(jié)習(xí)題
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _20180727
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string [] names =new string [8]{? "吳松" , "錢東宇", "伏晨" ,? "陳陸" , "周瑞" , "林日彭" , "何坤" ,? "關(guān)欣" };
? ? ? ? ? ? int[] score = new int[8] { 89, 90, 98, 56, 60, 91, 93, 85 };
? ? ? ? ? ? int max = 0;
? ? ? ? ? ? int j= 0;
? ? ? ? ? ? for (int i = 0; i < score.Length;i++ )
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (max < score[i])
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? max = score[i];
? ? ? ? ? ? ? ? ? ? j = i;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ?
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine("分?jǐn)?shù)最高的是" + names [j]+"," + "分?jǐn)?shù)是" + max );
? ? ? ? ? ??
? ? ? ? }
? ? }
}
我看到別人這樣寫,但是我不知道具體的意思,有大神能解釋這些語句嗎?謝謝
2018-08-11
不行,要初始化
2018-07-30
循環(huán)遍歷score數(shù)組所有的值,如果max變量小于當(dāng)前score值就將score值附給max變量,數(shù)組遍歷完后max變量會獲得score數(shù)組中最大的值,之后輸出max即可;