string[,] score = new string[6, 2] { {"吳松", "89"}, {"錢東宇", "90"}, {"伏晨", "98"}, {"陳陸", "56"}, {"周蕊", "60"},{"林日鵬", "60"} };
int x = 0;
for (int i = 0; i <score.GetLongLength(0); i++)
if(int.Parse(score[x,1]) < int.Parse(score[i,1]))
x = i;
int x = 0;
for (int i = 0; i <score.GetLongLength(0); i++)
if(int.Parse(score[x,1]) < int.Parse(score[i,1]))
x = i;
a=0; b=++a; // 相當于a=a+1;b=a; 結果是a=1,b=1
a=0; b=a++; // 相當于b=a;a=a+1; 結果是a=1,b=0
a=0; b=a++; // 相當于b=a;a=a+1; 結果是a=1,b=0
2016-11-22
實際上新建一個變量來儲存結果,是方便起來其他地方的調用,如果我們在代碼的其他部分,想要知道結果,不必來重新開始循環,而是訪問這個變量即可。
2016-11-22
string[] NAMES = { "吳松", "錢東宇", "伏晨", "陳路", "周陸", "林日鵬", "何昆", "關欣" };
int[] score = { 29, 90, 98, 56, 60, 91, 93, 85 }; int max= score[0];
int c = 0; for (int i = 1; i < score.Length; i++)
{ if (score[i] > max) {max= score[i];
c = i; } }Console.WriteLine("最高分數的是{0}分數是{1}", max, NAMES[c]);
int[] score = { 29, 90, 98, 56, 60, 91, 93, 85 }; int max= score[0];
int c = 0; for (int i = 1; i < score.Length; i++)
{ if (score[i] > max) {max= score[i];
c = i; } }Console.WriteLine("最高分數的是{0}分數是{1}", max, NAMES[c]);
x+" ":注意兩個雙引號之間是有空格的,可以將其看作是一個空字符串處理,變量和一個字符串使用“加法運算”,在之前的課程說了:將兩個字符串拼接成一個新的字符串
2016-11-20
else if (i == num.Length - 1)
{
Console.WriteLine("沒有7的整倍數,");
}
}
兄弟們這樣是對的
{
Console.WriteLine("沒有7的整倍數,");
}
}
兄弟們這樣是對的
for (int i = 0; i < num.Length; i++)
{
if (num[i] % 7 == 0)
{
Console.WriteLine("有7的整倍數");
break;
}
{
if (num[i] % 7 == 0)
{
Console.WriteLine("有7的整倍數");
break;
}