写一个“打字练习程序”,要求以下功能
按用户的练习从1级开始到10级
随机的出现A-Z,a-z
出现字符的长度和等级数相符
用户输入对得1分,错分数清0
每级为10分
当等级到11级或用户输入Exit则程序结束
1 int level = 1; int result = 0;
2 System.Console.Write("欢迎使用打字练习程序,按回车键开始");
3 System.Console.WriteLine("输入Exit退出)");
4
5 System.Console.ReadLine();
6 string inputStr = ""; string createStr = "";
7 System.Random r = new System.Random();
8 do
9 {
10 createStr = "";
11 for (int i = 1; i <= level; i++)
12 {
13 createStr += ((char)r.Next('A', 'Z' + 1)).ToString();
14 }
15 System.Console.WriteLine("等级:{0}分数:{1}请输入{2}",level, result, createStr);
16 inputStr = System.Console.ReadLine();
17 if (createStr == inputStr)
18 {
19 result++;
20 }
21 else
22 {
23 result = 0;
24 }
25 if (result == 10)
26 {
27 level++;
28 result = 0;
29 }
30 }
31 while (inputStr.ToLower() != "exit" && level <= 10);
2 System.Console.Write("欢迎使用打字练习程序,按回车键开始");
3 System.Console.WriteLine("输入Exit退出)");
4
5 System.Console.ReadLine();
6 string inputStr = ""; string createStr = "";
7 System.Random r = new System.Random();
8 do
9 {
10 createStr = "";
11 for (int i = 1; i <= level; i++)
12 {
13 createStr += ((char)r.Next('A', 'Z' + 1)).ToString();
14 }
15 System.Console.WriteLine("等级:{0}分数:{1}请输入{2}",level, result, createStr);
16 inputStr = System.Console.ReadLine();
17 if (createStr == inputStr)
18 {
19 result++;
20 }
21 else
22 {
23 result = 0;
24 }
25 if (result == 10)
26 {
27 level++;
28 result = 0;
29 }
30 }
31 while (inputStr.ToLower() != "exit" && level <= 10);