有一组学员的成绩{99,85,82,63, 60},将它们按升序排列。要增加一个学员的成绩,将它插入成绩序列,并保持升序。
using System.Collections;…………
Console.WriteLine("请输入新增成绩:");
int score = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("插入成绩的下标是:");
int num = Convert.ToInt32(Console.ReadLine());
ArrayList mylist = new ArrayList(6);
mylist.Add(99);
mylist.Add(85);
mylist.Add(82);
mylist.Add(63);
mylist.Add(60);
mylist.Insert(num, score);
mylist.Sort();
mylist.Reverse();
Console.WriteLine("新的排序为:");
foreach (var item in mylist )
{
Console.Write(item + "\t");
}
Console.ReadKey();
![image.png](https://img.haomeiwen.com/i14494607/d652436cfc2e42bd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
网友评论