5、从控制台输入一名学员的信息包括姓名和c#,SQL,unity3D三门功课的成绩,然后把三门功课的平均分输出到控制台

Console.WriteLine("请输入姓名");
String name = Console.ReadLine();
Console.WriteLine("C#成绩:");
String c = Console.ReadLine();
Console.WriteLine("sql成绩:");
String s = Console.ReadLine();
Console.WriteLine("unity成绩:");
String u = Console.ReadLine();
String avg = String.Format("{0:F}", (Double.Parse(c) + Double.Parse(s) + Double.Parse(u)) / 3);
Console.WriteLine("平均分是:" + avg);

指定数值里有几周,剩余几天

int all = 46;
int day = 7;
int num = all % day;
int wek = (all - num) / day;
Console.WriteLine("周数为:" + wek + "剩余天数:" + num);

用布尔校验张三李四成绩高低

int lisi = 80;
Console.WriteLine("请输入张三成绩:");
int zhangsan = int.Parse(Console.ReadLine());
Boolean status = lisi > zhangsan;
if (status)
{
    Console.WriteLine("张三比李四成绩低");
}
else
{
    Console.WriteLine("张三比李四成绩高");
}

用if判断张三李四成绩高低

Console.WriteLine("请输入张三成绩:");
int zhangsan = int.Parse(Console.ReadLine());
if (zhangsan>90)
{
    Console.WriteLine("奖励mp4");
}
else
{
    Console.WriteLine("不奖励");
}

用户输入两个数a,b.如果a能被b整除或a+b大于100,则a; 否输出b

Console.WriteLine("请输入a:");
int a = int.Parse(Console.ReadLine());
Console.WriteLine("请输入b:");
int b = int.Parse(Console.ReadLine());
if(a%b==0 || a + b > 100)
{
    Console.WriteLine(a);
}
else
{
    Console.WriteLine(b);
}

100以内偶数和

int sum = 0;
int num = 0;
while (num < 100)
{
    if (num % 2 == 0)
    {
        sum = sum + num;
    }
    num++;
}
//
int sun = 0;
for(int i = 0; i <= 100; i+=2)
{
    sun += i;
}
Console.WriteLine(sun);

当前年份为2006,产值为80000,每年增长百分之25,哪年才能年产200000

int year = 2006;
Double num = 80000;
while (true)
{
    num = num * 1.25;
    year++;
    if (num >= 200000)
    {
        break;
    }
}
Console.WriteLine(year);

已知圆半径求周长

Double pai = 3.1415926; 
Double res = pai * 1.5 * 1.5; 
Console.WriteLine(String.Format("{0:F}", res));

循环输入某同学S1结业考试的5门课成绩,并计算平均分

Double sum = 0;
for (int i = 0; i < 5; i++)
{
    Console.WriteLine("请输入5门功课中第" + (i + 1) + "门成绩:");
    Double num = double.Parse(Console.ReadLine());
    sum = sum + num;
}
Console.WriteLine("平均分为:" + sum / 5);

输入一个数字,做加法表

Console.Write("请输入一个值:");
int input = int.Parse(Console.ReadLine());
Console.WriteLine("根据这个值可输入如下加法表:");
int j = input;
for (int i = 0; i < input; i++)
{
    Console.WriteLine(i + " + " + (j --) + " = "+ (input));
}

1到100不能被3整除之和

int num = 0;
for (int i = 0; i < 100; i++) { 
    if (i % 3 != 0)
    {
        num += i;
    }
}
Console.WriteLine(num);

手动输入人数,算出大于30和小于30人数比例

Double max = 0;
Double sml = 0;
Console.Write("请输入总人数:");
int num = int.Parse(Console.ReadLine());
for (int i = 0; i < num; i++)
{
    Console.Write("请输入年龄:");
    int age = int.Parse(Console.ReadLine());
    if(age > 30)
    {
        max += 1;
    }
    else
    {
        sml += 1;
    }
}
Console.WriteLine("大于30的:{0}%人,小于30岁的{1}%人", max / 10 * 100, sml / 10 * 100);

输入5门成绩如果为负数则重新输入5门课,5门课程输入无误则算出总成绩和平均分

Double sum = 0;
Boolean status = true;
while (status)
{
    status = false;
    for (int i = 0; i < 5; i++)
    {
        Console.WriteLine("请输入5门功课中第" + (i + 1) + "门成绩:");
        Double num = double.Parse(Console.ReadLine());
        if (num > 0)
        {
            sum = sum + num;
        }
        else
        {
            Console.WriteLine("输入错误,请重新输入!");
            status = true;
            sum = 0;
            break;
        }
    }
}
Console.WriteLine("总分为{0},平均分为{1}", sum, sum / 5);

用数组写法算出5位同学平均分

int all = 0;
int[] num = new int[5];
for (int i = 0; i < 5; i++)
{
    Console.WriteLine("请输入数值:");
    num[i] = int.Parse(Console.ReadLine());

}
foreach (int i in num)
{
    all += i;
}
Console.WriteLine(all/ 5);

显示所有数组值,相加所有值,判断手动输入是否包含数组内数值

int[] n = new int[] { 8,4,2,1,23,344,12};
int all = 0;
foreach (int i in n)
{
    Console.WriteLine(i);
    all += i;
}
Console.WriteLine("总和为"+all);
Console.WriteLine("请输入数字:");
int input = int.Parse(Console.ReadLine());
Boolean status = false;
for (int i = 0; i < n.Length; i++)
{
    if (n[i] == input)
    {
        status = true;
        Console.WriteLine("输入的内容包含数组!");
        break;
    }
}
if (status == false) {
    Console.WriteLine("不包含");
}

冒泡排序

int[] arr = new int[5];
for (int i = 0; i < 5; i++)
{
    Console.WriteLine("请输入:");
    arr[i] = int.Parse(Console.ReadLine());
}
for (int i = 0;i < 5; i++)
{
    for (int j = 0;j<arr.Length -1-i;j++)
    {
        if (arr[j] > arr[j + 1])
        {
            int temp = arr[j];
            arr[j]= arr[j + 1];
            arr[j+1]= temp;
        }
    }
}
Console.WriteLine("结果");
foreach (int s in arr)
{
    Console.WriteLine(s);
}

3个班级各4名学员参赛,计算每个班级参赛学员的平均分

Double sum = 0;
for (int i = 0; i < 3; i++)
{
    Console.WriteLine("请输入第{0}个班级", i + 1);
    for (int j = 0; j < 5; j++)
    {
        Console.Write("请输入第{0}名学生成绩",j+1);
        Double one = Double.Parse(Console.ReadLine());
        sum += one;
    }
    Console.WriteLine("第{0}个班级平均分为{1}", i + 1, sum / 5);
    Console.WriteLine("\n");
}

循环输出直角三角形

Console.WriteLine("输入行号:");
int num = int.Parse(Console.ReadLine());
for (int i = 0; i < num; i++)
{
    for (int j = 0; j <= i; j++)
    {
        Console.Write("#");
    }
    Console.WriteLine("\n");
}

倒三角

Console.WriteLine("输入行号:");
int num = int.Parse(Console.ReadLine());
for (int i = num; i > 0; i--)
{
    for (int j = 0; j < i; j++)
    {
        Console.Write("#");
    }
    Console.WriteLine("\n");
}

等腰三角形

Console.WriteLine("输入行号:");
int num = int.Parse(Console.ReadLine());
for (int i = 1; i <= num; i++)
{
    for (int x = 1; x<=num-i; x++)
    {
        Console.Write(" ");
    }
    for (int j = 1; j <= 2 * i -1; j++)
    {
        Console.Write("#");
    }
    Console.WriteLine("");
    //

}

菱形