C 语言板球比分单

2024年8月28日 | 阅读 18 分钟

板球比分单项目是一个简单的 C 语言编程应用程序。它使用文件管理来存储数据,例如得分、失误、回合和额外分等。该程序可以显示得分、失误、击球员和投球手姓名、回合、奖金、投球手经济率、击球员击球率和其他统计数据。它还显示比赛的开始和结束时间。源代码详尽、无错误且易于理解。

  • 该项目的 C 语言源代码非常简单,仅包含七个用户定义的函数。它们在此处列出及其执行的任务。
  • void date() 可用于存储当前日期或比赛日期。
  • 使用 void printt() 方法以指定格式打印结果。
  • void filewrite() 用于将输入数据(如得分、失误、球数和回合)保存到计算机硬盘上的文件中。
  • void fileread() 用于读取或提取从已创建用于存储数据的文件中读取或提取数据。
  • 使用 void fileopen(char) 函数从计算机打开板球比分项目文件。
  • limitedinput(int) - 用于输入少量数据。
  • 使用 void newscoresheet() 方法创建一个新分数单。

运行板球比分单项目文件时会执行以下操作

项目开始时会出现欢迎屏幕,然后淡入显示主菜单。主菜单中有三个选项

  • 创建一个新的比分单。
  • 查看之前的比分单。
  • 退出

如果输入数字“1”,项目板球比分单将提示输入新比分单的名称。文件创建后,屏幕上会出现通知。然后用户必须填写比分单,其中需要以下详细信息

  • 比赛\场地
  • 比赛双方和获胜的抛球方
  • 抽签获胜者选择
  • 日期和轮次
  • 每位击球员的姓名和每位击球员的得分
  • 列出每位投球手的姓名和失分

输入这些信息后,程序将要求用户按“e”进行编辑,“c”继续。用户从主菜单中选择“2”后,应用程序将要求输入文件名。如果找到文件,则会显示。否则,屏幕上会显示错误消息。主菜单中的第三个选项是退出。如果在主菜单中输入数字“3”,板球比分单项目将终止。

程序分解

创建击球员结构。

创建投球手结构。

在程序的 main 函数中,将提示用户输入选择。

上述代码将处理击球员的比分详情。

上述代码将处理投球手的详情。

如果用户选择了选项 1 来添加击球员的详细信息,则上述代码将生效。

如果用户选择了选项 2 来添加投球手的详细信息,则上述代码将生效。

如果用户想查看比赛摘要并选择选项 3,则上述代码将生效。

上述代码将显示击球员的最高得分、击球员的最大四分、击球员的最大六分以及投球手获得的最大失误。

如果用户想退出系统,则上述代码将处理。

C 语言板球比分单项目

输出

Enter the Batsman detail:
Enter the number of batsman:
 4
Enter name of batsman1:
Rohit
Enter the number of ones scored by player1:
 1
Enter the number of twos scored by player1:
 2
Enter the number of threes scored by player1:
 3
Enter the number of fours scored by player1:
 4
Enter the number of sixes scored by player1:
 6
Enter the balls played by the player1:
50
Enter name of batsman2:
Virat
Enter the number of ones scored by player2:
 1
Enter the number of twos scored by player2:
 4
Enter the number of threes scored by player2:
 2
Enter the number of fours scored by player2:
 2
Enter the number of sixes scored by player2:
 1
Enter the balls played by the player2:
33
Enter name of batsman3:
Hardik
Enter the number of ones scored by player3:
 4
Enter the number of twos scored by player3:
 1
Enter the number of threes scored by player3:
 1
Enter the number of fours scored by player3:
 1
Enter the number of sixes scored by player3:
 1
Enter the balls played by the player3:
35
Enter name of batsman4:
Shikhar
Enter the number of ones scored by player4:
 1
Enter the number of twos scored by player4:
 4
Enter the number of threes scored by player4:
 2
Enter the number of fours scored by player4:
 2
Enter the number of sixes scored by player4:
 2
Enter the balls played by the player4:
24

Enter the bowlers details:
Enter the number of bowlers:
2

Enter name of bowler1:Kunal
Enter the runs given by the bowler1:
 23
Enter the overs bowled by the bowler1:
3
Enter the wickets taken by the bowler1
0

Enter name of bowler2:Jadeja
Enter the runs given by the bowler2:
 43
Enter the overs bowled by the bowler2:
20
Enter the wickets taken by the bowler2
0
Thank you all details are recorded
Enter the choice:
 1)Batsman detail:
 2)Bowlers detail:
 3)Match summary:
 4)Record:
 5)Exit
Enter the batsman number to see his details
1
                       

                                                           Player Detail
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Batsman        runs           balls        fours       sixes         sr
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Rohit           66             50            4           6           132.00
Enter the choice:
 1)Batsman detail:
 2)Bowlers detail:
 3)Match summary:
 4)Record:
 5)Exit
Enter the batsman number to see his details
2
                       Player Detail
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Batsman        runs           balls        fours       sixes         sr
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Virat           29             33            2           1           87.88
Enter the choice:
 1)Batsman detail:
 2)Bowlers detail:
 3)Match summary:
 4)Record:
 5)Exit
                    Match summary
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Batsman        runs           balls        fours       sixes         sr
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Rohit           66             50            4           6           132.00

TOTAL RUNS:66
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Bowler        overs           runs        wicket       economy
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Kunal           3              23            0           7.00
 Jadeja          20             43            0           2.00
Highest runs scored by the batsman:66
Maximum fours scored by the batsman:4
Maximum sixes scored by the batsman6:
Maximum wickets taken by the bowler:0
Enter the choice:
 1)Batsman detail:
 2)Bowlers detail:
 3)Match summary:
 4)Record:
 5)Exit

下一主题C/C++ 棘手程序