📄 program.cs
字号:
// 计算10个学生成绩的通过率,并以此判断是否可以提高学费
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo3
{
class Program
{
static void Main(string[] args)
{
// 变量声明及其初始化
int results; // 一个学生的成绩
int counter = 1; //学生个数
int passed = 0; //通过个数
int failed = 0; //挂了的个数
float rate; //通过率
while(counter<= 10){
Console.Write("请输入第"+counter+"学生的成绩(通过:0,挂了:1):");
results = Int32.Parse(Console.ReadLine ());
if (results == 0)
passed++;
else
failed++;
counter++;
}
rate = (float)passed / 10;
if (rate >= 0.8)
Console.WriteLine("\n可以提高学费!");
Console.ReadLine();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -