日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > C# >内容正文

C#

c#复习-2

發(fā)布時間:2023/12/20 C# 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c#复习-2 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
輸入三個學(xué)生的信息
學(xué)號、姓名、分?jǐn)?shù)
從大到小排序
1
using System; 2 using System.Collections; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Text; 6 7 namespace 復(fù)習(xí)CS 8 { 9 class Program 10 { 11 struct Student 12 { 13 public int num; 14 public string Code; 15 public string Name; 16 public decimal Score; 17 } 18 19 static void Main(string[] args) 20 { 21 //1、循環(huán)添加學(xué)生信息 22 ArrayList list = new ArrayList(); 23 24 for (int i = 1; i < 4; i++) 25 { 26 Student s = new Student(); //實(shí)例化 27 28 Console.Write("請輸入第" + i + "個學(xué)生的學(xué)號:"); 29 s.Code = Console.ReadLine(); 30 Console.Write("請輸入第" + i + "個學(xué)生的姓名:"); 31 s.Name = Console.ReadLine(); 32 Console.Write("請輸入第" + i + "個學(xué)生的成績:"); 33 s.Score = Convert.ToDecimal(Console.ReadLine()); 34 s.num = i; 35 36 list.Add(s); 37 Console.WriteLine("==============================="); 38 } 39 40 Console.WriteLine("-----------------------學(xué)生數(shù)據(jù)展示--------------------------"); 41 42 //2、排序 43 44 for (int i = 0; i < list.Count - 1; i++) 45 { 46 for (int j = i + 1; j < list.Count; j++) 47 { 48 Student s1 = (Student)list[i]; 49 Student s2 = (Student)list[j]; 50 51 if (s1.Score < s2.Score) 52 { 53 Object ob = list[i]; 54 list[i] = list[j]; 55 list[j] = ob; 56 } 57 } 58 } 59 60 //3、打印 61 foreach (object o in list) 62 { 63 Student ss = (Student)o; 64 Console.WriteLine("" + ss.num + "個學(xué)生的學(xué)號:" + ss.Code + ",姓名:" + ss.Name + ",分?jǐn)?shù):" + ss.Score + ""); 65 } 66 67 68 69 Console.ReadKey(); 70 } 71 } 72 }

轉(zhuǎn)載于:https://www.cnblogs.com/tonyhere/p/5592236.html

總結(jié)

以上是生活随笔為你收集整理的c#复习-2的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。