C++歌手大赛系统

本文介绍了使用C++编程实现的歌手大赛系统,包括Player类和System类的设计,以及在Main.cpp中的运行流程。通过该项目,作者强调了学习过程中的积累和勇于探索的精神。
摘要由CSDN通过智能技术生成

项目结构

       选手类(Player)
       操作类(System)  // 老师说最好别用这个名字,以后一定要注意这个问题

在这里插入图片描述

Player类

这一部分代码是写在头文件里的

#define TheJudgesNum 10
class Player
{
   
private:
public:
 char num[20];
 char name[20];
 int score[TheJudgesNum];
 float sum;
 float ave;
 Player *next;
 Player();
 ~Player();
 int getMaxScore();
 int getMinScore();
};

Player.cpp立马跟上

#include "Player.h"
#include <iostream>
using namespace std;
int Player::getMaxScore() {
   
 int Maxscore = score[0];
 for (int i = 1; i < TheJudgesNum; i++) {
   
  if (score[i] > Maxscore) {
   
   Maxscore = score[i];
  }
 }
 return Maxscore;
}
int Player::getMinScore() {
   
 int Minscore = score[0];
 for (int i = 1; i < TheJudgesNum; i++) {
   
  if (score[i] < Minscore) {
   
   Minscore = score[i];
  }
 }
 return Minscore;
}
Player::Player()
{
   
 for (int i = 0; i < TheJudgesNum; i++) {
   
  score[i] = 0;
 }
 sum = 0;
 ave = 0;
}
Player::~Player()
{
   
}

emmm怎么不是4个字符缩进,看起来好奇怪

System类

#pragma once
#include"Player.h"
class System
{
   
private:
 int PlayerNum;
 Player *Head;
 Player *End;
public:
 void Interface();
 void Run();
 void InputPlayerInformation();
 void OutputPlayerInformation();
 void GiveScore();
 void Sort();
 void Swap(Player *A,Player *B);
 bool Search(char ch[20],int i);
 void WriteDataFile();
 void AddPlayerInformation();
 void ReadDataFile();
 System();
 ~System();
};

System.cpp

#include "Player.h"
#include "System.h"
#include <string> 
#include <fstream> 
#include <iostream>
using namespace std;
void System::Interface() {
   
 cout << endl;
 cout << "                                       ***************菜单****************" << endl;
 cout << "                                       ***    1——录入选手信息        ***" << endl;
 cout << "                                       ***    2——信息输出            ***" << endl;
 cout << "                                       ***    3——评委打分            ***" << endl;
 cout << "                                       ***    4——成绩排序(平均分)  ***" << endl;
 cout << "                                       ***    5——数据查询            ***" << endl;
 cout << "                                       ***    6——追加选手信息        ***" << endl;
 cout << "                                       ***    7——写入数据文件        ***" << endl;
 cout << "                                       ***    0——退出系统            ***" << endl;
 cout << "                                       ***********************************" << endl;
 cout << endl;
 cout << "                                       ***********************************" << endl;
 cout << "                                       ***    请选择想要进行的操作     ***" << endl;
 cout << "                                       ***********************************" << endl;
}
void System::Run() {
   
 int choice = 1;
 while (choice) {
   
  Interface();
  cin >> choice;
  if (choice > 7 || choice < 0) {
   
   cout << "                                       ****************************
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值