⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 program.cs

📁 C#2.0宝典源码,C#经典书籍,很多例子
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

namespace Example9_10 {
    class Program {
        static void Main(string[] args) {
            //定义程序中用到的变量,用scores数组存储分数,另外两个双精度变量存储总分和平均分。
            double[] scores = new double[10] { 80, 75, 89, 92, 64, 73, 53, 96, 74, 88 };
            double all = 0.0;
            double average = 0.0;

            foreach (double score in scores) {
                //输出数组中的原始成绩。
                Console.WriteLine("原始分数:{0}", score);

                //累加分数
                all += score;
            }
            //求平均值
            average = all / 10;

            Console.WriteLine("平均成绩为:{0}", average);
            Console.ReadLine();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -