本帖最后由 张大海 于 2013-4-14 21:33 编辑
- int[] score = { 10,20,30,40,50,60,70};
- //int[] score = { 70,60,50,40,30,2,1};
- //int[] score = {8,12,2,78,35,45,56,69,1,89,57,32,45,78 };
- int i,j;
- for ( i=0;i<score .Length -1;i++)
- {
- for ( j = 0; j < score.Length - j - 1;j ++ )
- {
- if (score [j ]<score [j +1])
- {
- int sum = 0;
- sum =score [j ];
- score[j] = score[j + 1];
- score [j+1]=sum ;
-
- }
- }
-
- }
- for (i = 0; i < score.Length;i++ )
- {
- Console.WriteLine(score [i ]);
- }
- Console.ReadKey();
复制代码 结果是40 30 20 10 50 60 70 这神马情况???求大神帮忙看下 |