使用系統。集合。泛型;
使用系統。Linq
使用系統。文本;
使用系統。線程。任務;
命名空間學生管理器
{
公共類GetRandom
{
私有靜態隨機ran = new Random();
公共靜態double getRandom()
{
雙結果= 0;
結果=冉。next double()* 100+1;
result = result & gt100 ?100:結果;
結果=雙精度。解析(結果。ToString(" 0.0 "));//保留兩位有效數字。
返回結果;
}
}
公共課學生
{
公共學生(字符串名稱,整數)
{
this.name = name
this.age =年齡;
//自動生成結果
this . chinesescore = get random . get random();
this . math score = get random . get random();
this . English score = get random . get random();
}
公共字符串名稱{ get設置;}
public int age { get設置;}
public double chineseScore { get設置;}
public double mathScore { get設置;}
公共雙英語分數{ get設置;}
public double getTotalScore()
{
返回Chinese score+math score+English score;
}
}
班級計劃
{
公共靜態字典& ltint,student & gtStdDic =新詞典& ltint,student & gt();
靜態void Main(string[] args)
{
列表& lt學生& gtstdList =新列表& lt學生& gt();
StdList。加(新生(“張三蛋”,16));
StdList。加(新生(“李四狗”,16));
StdList。加(新生(“王武池”,16));
StdList。添加(新生(“趙”,16));
StdList。加(新生(“馮寶寶”,16));
StdList。加(新生(“錢馬爾”,16));
StdList。添加(新生(“匿名”,16));
StdList。加(新生("隨便",16));
StdList。加(新生(“劉吵”,16));
StdList。加(新生(“黃叔叔”,16));
int index = 1;
while (stdList。Count & gt1)
{
student temp = STD list[0];
for(int I = 1;我& ltstdList。數數;i++)
{
if (stdList[i].getTotalScore()& lt;Temp.getTotalScore())//升序
{
temp = stdList[I];
}
}
StdDic。Add(index,temp);
index++;
stdList。移除(臨時);
}
StdDic。Add(index,stdList[0]);
foreach(StdDic中的變量項)
{
控制臺。WriteLine(項目。Value.name + ":" + item。value . gettotalscore());//打印信息
}
控制臺。ReadLine();
}
}
}
自己跑壹下看看