zoukankan      html  css  js  c++  java
  • [C#]P1实训学生管理系统

    ******************************
    * 1 学生成绩录入 *
    * 2 学生成绩查询 *
    * 3 课程成绩分析 *
    * 4 退出系统 *
    ******************************
    请选择:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace p1_1022
    {
        class Program
        {
    
            private static int[][] Score;
            private static bool[] bA;
    
            static void Main(string[] args)
            {
                int iA;//人数
    
                Console.Write("请输入学生人数:");
                iA = Convert.ToInt32(Console.ReadLine());
                Score = new int[iA][];
                bA = new bool[iA];
                for (int i = 0; i < iA; i++)
                {
                    Score[i] = new int[5];
                }
                ///////////////////////////////////////////
                while (true)
                {
                    Console.WriteLine("    ******************************");
                    Console.WriteLine("    *    1  学生成绩录入         *");
                    Console.WriteLine("    *    2  学生成绩查询         *");
                    Console.WriteLine("    *    3  课程成绩分析         *");
                    Console.WriteLine("    *    4  退出系统             *");
                    Console.WriteLine("    ******************************");
                    int iB = Convert.ToInt32(Console.ReadLine());
                    switch (iB)
                    {
                        case 4:
                            return;
                        case 3:
                            if (bA[0] == false)
                            {
                                Console.WriteLine("成绩未录入,不能分析,请重新选择!");
                                break;
                            }
                            Analysis();
                            break;
                        case 2:
                            if (bA[0] == false)
                            {
                                Console.WriteLine("成绩未录入,不能分析,请重新选择!");
                                break;
                            }
                            Query();
                            break;
                        case 1:
                            Console.Write("1、按学号输入 2、按科目输入");
                            iB = Convert.ToInt32(Console.ReadLine());
                            if (iB == 1)
                            {
                                Input();
                                bA[0] = true;
                                break;
                            }
                            if (iB == 2)
                            {
                                G();
                                bA[0] = true;
                                break;
                            }
                            Console.WriteLine("输入不合法,请从新输入!");
                            break;
                        default:
                            Console.WriteLine("输入不合法,请从新输入!");
                            break;
                    }
    
                }
            }
            static void Analysis()
            {
                int iA, iMax, iMin, iSun = 0;
                int[] iB = new int[5];
    
                Console.WriteLine("请问要按那一科成绩输入(1语文2数学3外语):");
                iA = Convert.ToInt32(Console.ReadLine());
                iMax = Score[0][iA];
                iMin = Score[0][iA];
                for (int i = 0; i < Score.Length; i++)
                {
                    if (Score[i][iA] > iMax)
                    {
                        iMax = Score[i][iA];
                    }
                    if (Score[i][iA] < iMin)
                    {
                        iMin = Score[i][iA];
                    }
                    iSun = iSun + Score[i][iA];
    
    
                    switch ((int)(Score[i][iA] / 10))
                    {
                        case 10:
                        case 9:
                            iB[4]++;
                            break;
                        case 8:
                            iB[3]++;
                            break;
                        case 7:
                            iB[2]++;
                            break;
                        case 6:
                            iB[1]++;
                            break;
                        default:
                            iB[0]++;
                            break;
                    }
    
    
                }
                Console.WriteLine("最高成绩为:" + iMax);
                Console.WriteLine("最低成绩为:" + iMin);
                Console.WriteLine("平均成绩为:" + iSun / Score.Length);
                Console.WriteLine("分数在90~100人数:" + iB[4]);
                Console.WriteLine("分数在80~89人数:" + iB[3]);
                Console.WriteLine("分数在70~79人数:" + iB[2]);
                Console.WriteLine("分数在60~69人数:" + iB[1]);
                Console.WriteLine("分数在0~59人数:" + iB[0]);
    
    
    
            }//OK
            static void Query()
            {
                int iA = 0;
    
                while (true)
                {
                    Console.WriteLine("请输入要查询的学生学号,输入-1则退出查询!");
                    iA = Convert.ToInt32(Console.ReadLine());
                    if (iA == -1)
                    {
                        break;
                    }
    
                    for (int i = 0; i < Score.Length; i++)
                    {
                        if (Score[i][0] == iA)
                        {
                            bA[2] = true;
                            Console.WriteLine("------------------------------------------------------");
                            Console.WriteLine("学号\t语文\t数学\t外语\t总分\t");
                            Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", Score[i][0], Score[i][1], Score[i][2], Score[i][3], Score[i][4]);
                        }
    
                    }
                    if (bA[2] == false)
                    {
                        Console.WriteLine("未查询到该学号!");
                    }
                    bA[2] = false;
                }
            }//OK
            static void Input()
            {
                for (int i = 0; i < Score.Length; i++)
                {
                    Console.WriteLine("请输入学号:");
                    Score[i][0] = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("请输入语文:");
                    Score[i][1] = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("请输入数学:");
                    Score[i][2] = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("请输入外语:");
                    Score[i][3] = Convert.ToInt32(Console.ReadLine());
                    Score[i][4] = Score[i][1] + Score[i][2] + Score[i][3];
                }
            }//OK
            static void G()
            {
                int iB;
                Console.WriteLine("请问要按那一科成绩输入(1语文2数学3外语):");
                iB = Convert.ToInt32(Console.ReadLine());
                if (iB == 1 || iB == 2 || iB == 3)
                {
                    InputG(iB);
                    return;
                }
                Console.WriteLine("输入不合法,请从新输入!");
                return;
            }//OK
            static void InputG(int a)
            {
                for (int i = 0; i < Score.Length; i++)
                {
                    Console.WriteLine("请输入学号:");
                    Score[i][0] = Convert.ToInt32(Console.ReadLine());
                    if (a == 1)
                    {
                        Console.WriteLine("请输入语文:");
                    }
                    if (a == 2)
                    {
                        Console.WriteLine("请输入数学:");
                    }
                    if (a == 3)
                    {
                        Console.WriteLine("请输入外语:");
                    }
                    Score[i][a] = Convert.ToInt32(Console.ReadLine());
                }
            }//OK
    
        }
    }
  • 相关阅读:
    javascript 使用链式结构
    javascript 闭包
    javascript 使用canvas绘画
    (14)javascript 函数表达式 递归、闭包
    (13)javascript 面向对象 创建对象
    wpf和winform的区别
    XtraReport1添加参数
    {$DEFINE WANYI}
    $('#myModal').modal('show') //显示$('#myModal').modal('hide')隐藏
    计算机音视频技术
  • 原文地址:https://www.cnblogs.com/Wzqa/p/2958787.html
Copyright © 2011-2022 走看看