4e1548abe2
Part1
50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using System;
|
|
namespace Lesson8
|
|
{
|
|
class program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
#region 输入数字练习
|
|
try
|
|
{
|
|
Console.Write("请输入一个数字:");
|
|
int num = int.Parse(Console.ReadLine());
|
|
Console.WriteLine($"你输入的数字是: {num}");
|
|
}
|
|
catch
|
|
{
|
|
Console.WriteLine("请你输入一个数字");
|
|
}
|
|
finally
|
|
{
|
|
Console.WriteLine("程序执行完毕!");
|
|
}
|
|
#endregion
|
|
|
|
#region 录入成绩练习
|
|
try
|
|
{
|
|
int yuWen, shuXue, yingYu;
|
|
Console.Write("请你输入你的名字:");
|
|
string name = Console.ReadLine();
|
|
Console.Write("请你输入你的语文成绩:");
|
|
yuWen = int.Parse(Console.ReadLine());
|
|
Console.Write("请你输入你的数学成绩:");
|
|
shuXue = int.Parse(Console.ReadLine());
|
|
Console.Write("请你输入你的英语成绩:");
|
|
yingYu = int.Parse(Console.ReadLine());
|
|
Console.WriteLine($"你的语文成绩是:{yuWen},你的数学成绩是{shuXue},你的英语成绩是:{yingYu}.");
|
|
}
|
|
catch
|
|
{
|
|
Console.WriteLine("成绩录入时发生了错误");
|
|
}
|
|
finally
|
|
{
|
|
Console.WriteLine("成绩录入完毕!");
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
} |