亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

這樣可行嗎???

string[]name=new string{名字}; int[]sorce=new int[]{分數}; int max=0; int i=0; for(int x in sorce) { if(x>=max) { max=x; i++;}} ? ? Console.Write("分數最高為{0}"+name[i]+",分數是{1}"+sorce[i]); 這樣可行嗎???

正在回答

3 回答

string[]name=new string[]{"吳松","前東宇","伏晨","陳陸","周瑞","林日鵬","何坤","關欣"};

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

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

? ? ? ? ? ? int y = 0; int x;//x為sorce數組的索引號,y為name數組的所以號

? ? ? ? ? ? for(x=0;x<sorce.Length;x++)

? ? ? ? ? ? {

? ? ? ? ? ? ? if(sorce[x]>max)

? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? max=sorce[x];

? ? ? ? ? ? ? ? y=x;

? ? ? ? ? ? ? }

? ? ? ? ? ? ?}

? ? ? ? ? ? Console.Write("分數最高的是{0}"+",分數是{1}",name[y],max);

//改成這樣就對了,運行過了

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

郭榮俊GG 提問者

非常感謝!
2016-03-28 回復 有任何疑惑可以回復我~

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

? ? class Program

? ? {

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

? ? ? ? {

? ? ? ? ? ? ?string []name={"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關欣"};

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

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

? ? ? ? ? ? string maxname=name[0];

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

? ? ? ? ? ? {

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

? ? ? ? ? ? ? ? {

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

? ? ? ? ? ? ? ? ? ? maxname=name[i];

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? ? ? Console.WriteLine("分數最高的是{0},分數是{1}",max,maxname);

? ? ? ? }

? ? }

}


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

?string[]name=new string[]{"吳松","前東宇","伏晨","陳陸","周瑞","林日鵬","何坤","關欣"};
????????? int[]sorce=new int[]{89,90,98,56,60,91,93,85};
????????? int max=sorce[0];
????????? int y=0;
????????? for(int x=0;x<=sorce.Length;x++)
????????? {
????????????? if(sorce[x]>max)
????????????? {
????????????? max=sorce[x];
????????????? y=x;
????????????? }
????????? }
??????????? if( max=sorce[x])
?????????????
????????? Console.Write("分數最高的是{0}"+",分數是{1}",name[y],max);

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

舉報

0/150
提交
取消
C#開發輕松入門
  • 參與學習       256143    人
  • 解答問題       1527    個

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

進入課程

這樣可行嗎???

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號