zoukankan      html  css  js  c++  java
  • 课堂题目54

    课堂题目5-4

    课程元素类型 任务

    输入某班10名同学语文、数学、英语期末考试成绩,输出各门课程平均成绩。

    总结:二维数组开端

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace _5_4
    {
        class Program
        {
            static void Main(string[] args)
            {
                double[,] dA = new double[3, 3]; //存放成绩数组
                string[] szA = new string[] { "语文", "数学", "英语" }; //课程名
                double[] dB = new double[3];//存放平均成绩
                double dC;//临时统计
    
                dC = 0.0;
    
    
    
                //*
                //
                //*         输入成绩并保存到数组
                //
                //*
    
    
                for (int i = 0; i < dA.GetLength(0); i++)
                {
                    for (int j = 0; j < dA.GetLength(1); j++)
                    {
                        Console.Write("请输入第{0}个同学的{1}成绩:", j + 1, szA[i]);
                        dA[i, j] = Convert.ToDouble(Console.ReadLine());
    
                    }
                    Console.WriteLine("{0}成绩统计完毕!",szA[i]);
                }
                Console.WriteLine("--------------------------");
                //*
                //
                //*         统计每门课的平均成绩
                //
                //*
                Console.WriteLine("每门课的班级平均成绩为:");
                for (int i = 0; i < dA.GetLength(0); i++)
                {
                    for (int j = 0; j < dA.GetLength(1); j++)
                    {
    
                        dC = dC + dA[i, j];
                    }
                    Console.WriteLine("{0}的平均成绩为{1}", szA[i], dC / dA.GetLength(1));
                    dC = 0.0;
                }
                Console.WriteLine("--------------------------");
                //*
                //
                //*         统计同学的平均成绩
                //
                //*
                for (int i = 0; i < dA.GetLength(1); i++)
                {
                    for (int j = 0; j < dA.GetLength(0); j++)
                    {
    
                        dC = dC + dA[j, i];
                    }
                    Console.WriteLine("第{0}同学的平均成绩为{1}", i+1,dC / dA.GetLength(0));
                    dC = 0.0;
                }
                Console.WriteLine("--------------------------");
                Console.ReadKey(true);
    
            }
        }
    }
  • 相关阅读:
    Ubuntu 18.04 安装博通(Broadcom)无线网卡驱动
    Python3漏洞扫描工具 ( Python3 插件式框架 )
    Linux 防火墙
    基于Python3的漏洞检测工具 ( Python3 插件式框架 )
    git学习笔记
    sublime text 3 优化配置
    win10 出现0x80072efd错误
    Ubuntu搭建NFS服务器,NFS协议详细分析
    docker实现跨主机连接
    Python-RabbitMQ(持久化)
  • 原文地址:https://www.cnblogs.com/Wzqa/p/2792176.html
Copyright © 2011-2022 走看看