2018-12-12有一组学员的成绩{99,85,82,63, 60},将它们按升序排列。要增加一个学员的成绩,将它插入成绩序列,并保持升序
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入新增成绩:");
int c = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("插入成绩的下标是:");
int b = Convert.ToInt32(Console.ReadLine());
ArrayList list = new ArrayList();
list.Add(85);
list.Add(99);
list.Add(82);
list.Add(63);
list.Add(60);
list.Insert(b, c);
list.Sort();
list.Reverse();
Console.WriteLine("新的排序为:");
foreach (var item in list)
{
Console.Write(item + "\t");
}
Console.ReadKey();
网友评论