要求用户输入学生人数和分数的程序,然后计算每个学生的平均值 [英] program that ask the user to Enter the number of student and numbers of marks then calculate the average for every student

查看:191
本文介绍了要求用户输入学生人数和分数的程序,然后计算每个学生的平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int sum = 0;

           双倍平均;

            Console.Write("输入学生人数=");

            int N = int.Parse(Console.ReadLine());

            Console.Write("输入标记数量=");

            int M = int.Parse(Console.ReadLine());

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int I = 1; I< = N; I ++)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int Y = 1; Y< = M; Y ++)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write("标记"+ Y +"="");

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int Mark = int.Parse(Console.ReadLine());

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;总和+ =马克;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; avg = sum / M;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine("学生的平均值="+平均值);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ReadKey();

int sum = 0;
            double avg;
            Console.Write("Enter the Number of Student =");
            int N = int.Parse(Console.ReadLine());
            Console.Write("Enter the Number of Marks =");
            int M = int.Parse(Console.ReadLine());
            for (int I=1;I<=N;I++)
            {
                for(int Y=1;Y<=M;Y++)
              {
                  Console.Write("the mark"+Y+"=");
                  int Mark = int.Parse(Console.ReadLine());
                  sum += Mark;
              }
                avg = sum / M;
                Console.WriteLine("the average of the student=" + avg);
            }
            Console.ReadKey();

推荐答案

            double avg;
            Console.Write("Enter the Number of Student =");
            int N = int.Parse(Console.ReadLine());
            Console.Write("Enter the Number of Marks =");
            int M = int.Parse(Console.ReadLine());
            for (int I = 1; I <= N; I++)
            {
                int sum = 0;
                for (int Y = 1; Y <= M; Y++)
                {
                    Console.Write("the mark" + Y + "=");
                    int Mark = int.Parse(Console.ReadLine());
                    sum += Mark;
                }
                avg = (double)sum / M;
                Console.WriteLine("the average of the student=" + avg);
            }
            Console.ReadKey();




最好的问候

Vikram Manjare

请记住点击"标记为答案"解决您的问题的回复,并点击"取消标记为答案"如果不。这对阅读此主题的其他社区成员有益。


Best Regards
Vikram Manjare
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.


这篇关于要求用户输入学生人数和分数的程序,然后计算每个学生的平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆