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

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

這樣有什么問題?

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]+"分數(shù)是"+score[max,1]);
??????? }
??? }
}

正在回答

2 回答

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

0 回復 有任何疑惑可以回復我~

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] + "分數(shù)是" + score[max, 1]);

? ? ? ? }

? ? }

}

最大值,與最大值的下標是兩個值,需要兩個變量來單獨存放。

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

這樣有什么問題?

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

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

幫助反饋 APP下載

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

公眾號

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