第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

怎么錯了啊??

static void Main(string[] args)

? ? ? ? {

? ? ? ? ? int [] score=new int[]{89,90,98,56,60,91,93,85} ;

? ? ? ? ? char []name=new char[]{"吳松","錢東宇","伏晨","程陸","周蕊","林日鵬","何昆","關(guān)欣"};

? ? ? ? ? int k=0;

? ? ? ? ? int max=score[0];

? ? ? ? ? for(int i=0;i<score.Length;i++)

? ? ? ? ? {

? ? ? ? ? ? ? if(score[i]>max)

? ? ? ? ? ? ? ? max=score[i];

? ? ? ? ? ? ? ? k=i;

? ? ? ? ? }

? ? ? ? ??

? ? ? ? ? Console.Write("分?jǐn)?shù)最高的是{0},分?jǐn)?shù)是{1}",name[k],score[i]);


正在回答

3 回答


? ? ? ? ? ? int[] score = new int[] { 89, 90, 98, 56, 60, 91, 93, 85 };

? ? ? ? ? ? string[] name = new string[] { "吳松", "錢東宇", "伏晨", "程陸", "周蕊", "林日鵬", "何昆", "關(guān)欣" };?//首先char是字符,string才是字符串

? ? ? ? ? ? int k = 0;

? ? ? ? ? ? int max = score[0];

? ? ? ? ? ? for (int i = 0; i < score.Length; i++)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? if (score[i] > max)?//if里如果有多個語句的話要用括號括起來,不然k最后會等于score的數(shù)組長度,也就是k會定位到最后一個同學(xué)的名字

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? max = score[i];

? ? ? ? ? ? ? ? ? ? k = i;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }


? ? ? ? ? ? Console.Write("分?jǐn)?shù)最高的是{0},分?jǐn)?shù)是{1}", name[k], max);?//還有就是,i是for循環(huán)里的一個局部變量,在循環(huán)外面調(diào)用不到,但是max是全局變量,它存儲了score的最高分?jǐn)?shù),所以直接用max就好了

//加油吧,程序員。。。。

1 回復(fù) 有任何疑惑可以回復(fù)我~

string[,] chenji = { { "吳松", "錢東宇", "伏晨", "陳陸", "周蕊", "林日鵬", "何昆", "關(guān)欣" },

? ? ? ? ? ? ? ? ? ? ? { "89", "90", "98", "56", "60", "91", "93", "85" } };

int max = 0;

int indx = 0;


for (int i = 0; i < (chenji.Length / 2); i++)

{

? ? if (int.Parse(chenji[1, i]) > max)

? ? {

? ? ? ? max = int.Parse(chenji[1, i]);

? ? ? ? indx = i;

? ? }



}


Console.WriteLine($"{chenji[0, indx]}, {max}");?



//string[] names = { "吳松", "錢東宇", "伏晨", "陳陸", "周蕊", "林日鵬", "何昆", "關(guān)欣" };

//int[] scores = { 89, 90, 98, 56, 60, 91, 93, 85 };


//int max = 0;

//int idex = 0;


//for ( int i = 0; i < scores.Length; i++)

//{

//? ? if (scores[i] > max)

//? ? {

//? ? ? ? max = scores[i];

//? ? ? ? idex = i;




//? ? }


//}

//Console.WriteLine($"{names[idex]},{max}");


0 回復(fù) 有任何疑惑可以回復(fù)我~

我用的二維數(shù)組

string[,] scores = new string[2,8]{{"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關(guān)欣"},{"89","90","98","56","60","91","93","85"}};

???????????? int max = 0;
???????????? string name=null;
??????????? for(int i=0;i<8;i++){
??????????????? if(int.Parse(scores[1,i])>max){
??????????????????? max=int.Parse(scores[1,i]);
??????????????????? name = scores[0, i];
??????????????? }
??????????? }
??????????? Console.Write("分?jǐn)?shù)最高的是"+name+",分?jǐn)?shù)是"+max);

2 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
C#開發(fā)輕松入門
  • 參與學(xué)習(xí)       255647    人
  • 解答問題       1519    個

本門課程是C#語言的入門教程,將帶你輕松入門.NET開發(fā)

進(jìn)入課程

怎么錯了啊??

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號