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

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

這樣有什么問題?

using System;
using System.Collections.Generic;
using System.Text;

namespace projGetMaxScore
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? int max=0;
??????????? string [,]score={{"吳松","89"},{"錢東宇","90"},{"伏晨","98"},{"陳陸","56"},{"周蕊","60"},{"林日鵬","91"},{"何昆","93"},{"關(guān)欣","85"}}
??????????? for(int i=0;i<8;i++)
??????????? {
??????????????? if((int)score[i,1]>max)
??????????????? {
??????????????????? max=(int)score[i,1];
??????????????? }
??????????? }
??????????? Console.WriteLine("最高分的是"+score[max,0]+"分?jǐn)?shù)是"+score[max,1]);
??????? }
??? }
}

正在回答

2 回答

不能強(qiáng)制轉(zhuǎn)換string為int,你可以使用string.compare比較,Convert.toInt32轉(zhuǎn)換,int.Parse()轉(zhuǎn)換等

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

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

? ? class Program

? ? {

? ? ? ? static void Main(string[] args)

? ? ? ? {

? ? ? ? ? ? int max = 0;

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

? ? ? ? ? ? int fen = int.Parse(score[0, 1]);

? ? ? ? ? ? for (int i = 0; i < 8; i++)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? if (int.Parse(score[i, 1]) > fen)

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? fen = int.Parse(score[i, 1]);

? ? ? ? ? ? ? ? ? ? max = i;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? ? ? Console.WriteLine("最高分的是" + score[max, 0] + "分?jǐn)?shù)是" + score[max, 1]);

? ? ? ? }

? ? }

}

最大值,與最大值的下標(biāo)是兩個(gè)值,需要兩個(gè)變量來單獨(dú)存放。

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

舉報(bào)

0/150
提交
取消

這樣有什么問題?

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

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

幫助反饋 APP下載

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

公眾號(hào)

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