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);
    
            }
        }
    }
  • 相关阅读:
    excel成绩统计公式
    freebsd Cacti
    图片处理程序
    php 图片水印+文字水印函数,但是不能设置透明
    PHP计算两个时间之差的函数(年,月,周,日,小时,分钟,秒数)
    php图片水印(可以设置透明度)
    使用函数递归实现基于PHP和MySQL的动态树型菜单[转]
    PHP实现MYSQL备份
    FreeBSD备忘录转载
    超级简单但超级实用的 PHP 的 mysql 类
  • 原文地址:https://www.cnblogs.com/Wzqa/p/2792176.html
Copyright © 2011-2022 走看看