這樣可行嗎???
string[]name=new string{名字}; int[]sorce=new int[]{分?jǐn)?shù)}; int max=0; int i=0; for(int x in sorce) { if(x>=max) { max=x; i++;}} ? ? Console.Write("分?jǐn)?shù)最高為{0}"+name[i]+",分?jǐn)?shù)是{1}"+sorce[i]); 這樣可行嗎???
string[]name=new string{名字}; int[]sorce=new int[]{分?jǐn)?shù)}; int max=0; int i=0; for(int x in sorce) { if(x>=max) { max=x; i++;}} ? ? Console.Write("分?jǐn)?shù)最高為{0}"+name[i]+",分?jǐn)?shù)是{1}"+sorce[i]); 這樣可行嗎???
2015-12-18
舉報(bào)
2016-03-02
string[]name=new string[]{"吳松","前東宇","伏晨","陳陸","周瑞","林日鵬","何坤","關(guān)欣"};
? ? ? ? ? ? int[] sorce = new int[] { 89, 90, 98, 56, 60, 91, 93, 85 };
? ? ? ? ? ? int max=sorce[0];
? ? ? ? ? ? int y = 0; int x;//x為sorce數(shù)組的索引號(hào),y為name數(shù)組的所以號(hào)
? ? ? ? ? ? for(x=0;x<sorce.Length;x++)
? ? ? ? ? ? {
? ? ? ? ? ? ? if(sorce[x]>max)
? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? max=sorce[x];
? ? ? ? ? ? ? ? y=x;
? ? ? ? ? ? ? }
? ? ? ? ? ? ?}
? ? ? ? ? ? Console.Write("分?jǐn)?shù)最高的是{0}"+",分?jǐn)?shù)是{1}",name[y],max);
//改成這樣就對(duì)了,運(yùn)行過了
2016-03-28
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? ?string []name={"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關(guān)欣"};
? ? ? ? ? ? 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("分?jǐn)?shù)最高的是{0},分?jǐn)?shù)是{1}",max,maxname);
? ? ? ? }
? ? }
}
2015-12-18
?string[]name=new string[]{"吳松","前東宇","伏晨","陳陸","周瑞","林日鵬","何坤","關(guān)欣"};
????????? 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("分?jǐn)?shù)最高的是{0}"+",分?jǐn)?shù)是{1}",name[y],max);