這個為什么輸出沒有任何輸出結(jié)果呢
? ? ? ? ?int i,dx;
? ? ? ? ? ? ? string[] xm={"吳松","錢東宇","伏晨","陳陸","周薇","林日鵬","何昆","關(guān)欣"};
? ? ? ? ? ? ? int[] cj = { 89, 90, 98, 56, 60, 91, 93, 85 };
? ? ? ? ? ? ? ? ?dx = cj[0];
? ? ? ? ? ? ? ? ?i = 0;
? ? ? ? ? ? ? ? ?for (int k = 1; k < cj.Length; i++)
? ? {
? ? ? ? ? ? ? ? ? ? ?if (cj[k] > dx)
? ? ? ? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ? ? ? ?dx = cj[k];
? ? ? ? ? ? ? ? ? ? ? ? ?i = k;
? ? ? ? ? ? ? ? ? ? ?}
? ? }
? ? ? ? ? ? Console.WriteLine("分?jǐn)?shù)最高的是{0},分?jǐn)?shù)是{1}",xm[i],dx);
2019-07-24
?string[] name={"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關(guān)欣"};
????????? int[] num={89,90,98,56,60,91,93,85};
????????? int max=0;
????????? int x=0;
????????? for(int i=0;i<num.Length;i++)
????????? {
???????????? if(max<num[i])
???????????? {
???????????????? max=num[i];
???????????????? x=i;
???????????? }
????????? }
????????? Console.Write("分?jǐn)?shù)最高的是"+name[x]+",分?jǐn)?shù)是"+num[x]);
2019-07-03
string[,]? s = { { "吳松", "89" }, { "錢東宇", "90" }, { "伏晨", "98" }, { "陳陸", "56" }, { "周蕊", "60" }, { "林日鵬", "91" }, { "錢東宇", "90" }, { "何昆", "93" }, { "關(guān)欣", "85" } };?
? ? ? ? ??
?int max = 0;
? ? ? ? ? ? for (int i = 2; i <s.Length / 2 ; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (i==2) {
? ? ? ? ? ? ? ? ? ? if (int.Parse(s[0, 1]) < int.Parse(s[1, 1])) {
? ? ? ? ? ? ? ? ? ? ? ? max = int.Parse(s[1, 1]);
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else {
? ? ? ? ? ? ? ? ? ? ? ? max = int.Parse(s[i, 1]);
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (int.Parse(s[i, 1]) < max)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? max = max;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else {
? ? ? ? ? ? ? ? ? ? max = int.Parse(s[i, 1]);
? ? ? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ? ? ? }
? ? ? ? ? ? string name ="";
? ? ? ? ? ? for (int y = 0; y < s.Length / 2 ; y++) {
? ? ? ? ? ? ? ? if (int.Parse(s[y, 1]) == max)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? name = s[y, 0];
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ??
? ? ? ? ? ?Console.WriteLine("分?jǐn)?shù)最高的是"+name+","+"分?jǐn)?shù)是"+max);
? ? ? ? ? ??
2019-06-23
i++ 會超出數(shù)組長度.
2019-05-28
i++,改成k++試試