zoukankan      html  css  js  c++  java
  • 2016/06/28

    今天就写了个小程序,巩固昨天所学。

    题目为:

    输入姓名,语文分数,数学分数,英语分数到集合
    求语文总分,数学平均分,英语最高分以及英语最高分是谁
     
    代码如下:
     1             Console.Write("请输入班级人数:");
     2             int a = int.Parse(Console.ReadLine());
     3             ArrayList jh=new ArrayList();
     4             int sumy = 0;
     5             int sums = 0;
     6             for (int i = 0; i < a; i++)
     7             {
     8                 Console.WriteLine("请输入第{0}个人的姓名:",i+1);
     9                 jh.Add(Console.ReadLine());
    10                 Console.WriteLine("请输入第{0}个人的语文成绩:",i+1);
    11                 jh.Add(Console.ReadLine());
    12                 Console.WriteLine("请输入第{0}个人的数学成绩:",i+1);
    13                 jh.Add(Console.ReadLine());
    14                 Console.WriteLine("请输入第{0}个人的英语成绩:",i+1);
    15                 jh.Add(Console.ReadLine());
    16                 
    17             }
    18             for (int i = 3; i < a * 4; i = i + 4)
    19             {
    20                 for (int j = i; j < a * 4 - 4; j = j + 4)
    21                 {
    22                     if (int.Parse(jh[i].ToString()) < int.Parse(jh[j + 4].ToString()))
    23                     {
    24 
    25                         int huan = int.Parse(jh[i].ToString());
    26                         jh[i] = int.Parse(jh[j + 4].ToString());
    27                         jh[j + 4] = huan;
    28 
    29                         string o = jh[i - 3].ToString();
    30                         jh[i - 3] = jh[j + 1];
    31                         jh[j + 1] = o;
    32                     }
    33                 }
    34             }
    35 
    36             for (int i = 1; i < a * 4; i = i + 4)
    37             {
    38                 sumy += int.Parse(jh[i].ToString());
    39                 sums += int.Parse(jh[i+1].ToString());
    40  
    41             }
    42             Console.WriteLine("语文总分为:"+sumy);
    43             Console.WriteLine("数学平均分为;" + sums/a);
    44             Console.WriteLine("英语最高分的人为:"+jh[0]+"最高分为:"+jh[3]);
    45             Console.ReadLine();

    话不多说了,我要去想想用两个集合怎么玩

  • 相关阅读:
    firefox上网问题解决
    ubuntu内核的编译安装
    ubuntu常用命令
    source insight 添加文件类型
    ubuntu版本查看命令
    百年孤独与拉丁美洲历史--转载
    Guess Number Higher or Lower II--困惑
    Symmetric Tree
    一棵开花的树
    yii2 mysql数据库读写分离配置
  • 原文地址:https://www.cnblogs.com/blueteasama/p/5625038.html
Copyright © 2011-2022 走看看