已采纳回答 / Perona
代码是逐行编译,编译到这时候刚好是21,在输出之间age被赋值是20+1,即21。输出结果不受后来age-2的影响,如果把输出语句放到age-2之后就是19了。
2015-10-23
string[] name = new string[] {"姓名",字数不够自己写};
int[] score = new int[] { 89, 90, 98, 56, 60, 91, 93, 85 };int max;max = score[0];int index = 0;
for(int i=1;i<score.Length;i++){if (score[i] > max){max = score[i];index = i;}}Console.WriteLine("分数最高的是{0},"+"分数是{1}",name[index],max);
int[] score = new int[] { 89, 90, 98, 56, 60, 91, 93, 85 };int max;max = score[0];int index = 0;
for(int i=1;i<score.Length;i++){if (score[i] > max){max = score[i];index = i;}}Console.WriteLine("分数最高的是{0},"+"分数是{1}",name[index],max);