c#用ArrayList统计有多少个及格分数 并降序输出?
using System;
using System.Collections;
class Program
{
public static void Main(string[] args)
{
ArrayList al=new ArrayList();
int score,pass=0,nopass=0;
string s;
Console.WriteLine("请输入分数,每行一个,负数结束:");
while(true)
{
s=Console.ReadLine().Trim();
score=Convert.ToInt32(s);
if(score<0)
break;
if(score>=60)
pass++;
else
nopass++;
al.Add(score);
}
al.Sort();
al.Reverse();
Console.WriteLine("及格:{0},不及格:{1}",pass,nopass);
Console.WriteLine("按降序排序后的分数:");
for(int i=0;i<al.Count-1;i++)
Console.Write("{0},",al[i]);
Console.WriteLine("{0}",al[al.Count-1]);
Console.WriteLine("按任意键继续。。。");
Console.ReadKey(true);
}
}