猜拳游戏C++ 怎么添加排行榜,求代码--!--

猜拳游戏(面向对象 注册 登录 记录积分 排行榜)

#include
#include
#include
#include
#include
#include
#include
#include<stdio.h>
#include <stdlib.h> //函数库 随机函数
#include <time.h> //函数库 时间函数
void Menu();
void Register();//注册
void Login();//登录
void Game();
using namespace std;
int pscore=0,cscore=0;string pc_name;string name;//全局变量

void Menu()//===============================================================================Menu
{
cout<<endl<<"==========猜拳游戏=========="<<endl;
cout<<"请选择输入你的选项!"<<endl;
cout<<"1.登录"<<endl;
cout<<"2.注册"<<endl;
cout<<"3.结束游戏"<<endl;
cout<<"============================"<<endl;

int choice;//选择菜单
cin>>choice;
switch(choice)
{

case 1://登录
Login();//call function调用函数
break;
case 2://注册
Register();//call function调头函数
break;
case 3://退出
exit(EXIT_FAILURE);
default://退出
cout<<"重新选择"<<endl;
Menu();
break;
}
}

void Register()//=======================================================================Register
{
ofstream outFile("Users.txt");//把注册的ID、code保存到Users.txt文件当中
if(!outFile.is_open())//如果没有成功打开文件
{
cout<<"很遗憾,连接不上服务器";
cout<<"程序结束";
cin.get();
exit(EXIT_FAILURE);
}
string code;
cout<<"Please Enter members name请输入用户名名称: ";
cin.get();//吃掉空字符
getline(cin,name);
//占位,假设输入的用户名超出长度或太短

outFile<<name<<endl;//记录注册的资料到Users.txt文件中

cout<<"Please Enter members code请输入密码: ";
getline(cin,code);
//占位,假设输入的密码超出长度或太短
cout<<"注册成功!";
outFile<<code<<endl;//记录注册的资料到Users.txt文件中
outFile.close();
Menu();

}

void Login()//=================================================================Login
{
cin.get();
ifstream inFile;//定义ifstream对象
inFile.open("Users.txt");//读取Users.txt文件中的注册资料
if(!inFile.is_open())//如果文件没有成功打开
{
cout<<"很遗憾,连接不上服务器";
exit(EXIT_FAILURE);
}
string name;
string code;
string temp;
string temp0;
cout<<"Please Enter members name请输入用户名名称: ";
getline(cin,name);

while(getline(inFile,temp))//匹配用户名
{
    if(temp==name)//如果匹配用户名成功
    {
        cout<<"Please Enter members code请输入密码: ";//请输入密码
        getline(cin,code);//code
        getline(inFile,temp0);//匹配code
        if(temp0==code)//如果密码正确,登录成功
        {

            cout<<"登录成功";
            Game();
            //占位,登录成功应该转到程序主题
        }
        else
        {
            cout<<"密码错误!"<<endl;
            Menu();//返回菜单
        }
    }
    else
    {
        cout<<"没有这个用户名!"<<endl;
        Menu();
    }
}

}

//人的手势
int person()
{
int n;
cout<<"请选择您的手势 1.剪刀 2.石头 3.布"<<endl;
cin>>n;
switch(n)
{
case 1:cout<<name<<"出的手势是:石头\n"<<endl;break;//cout<<""<<endl;
case 2:cout<<name<<"出的手势是:剪刀\n"<<endl;break;
case 3:cout<<name<<"出的手势是:布\n"<<endl;break;
default:cout<<name<<"出的手势不符合范围\n"<<endl;
return n;
}

}

//计算机手势
int computer()
{
srand((unsigned)time(NULL));//时间种子
int m = rand()%3+1;//随机函数 1 2 3
switch(m)
{
case 1:cout<<pc_name<<"出的手势是:石头\n"<<endl;break;
case 2:cout<<pc_name<<"出的手势是:剪刀\n"<<endl;break;
case 3:cout<<pc_name<<"出的手势是:布\n"<<endl;break;
}
return m;

}

void compare(int x,int y)//比较================================================================compare
{
if((x==1&&y==2)||(x==2&&y==3)||(x==3&&y==1))
{cout<<"恭喜"<<name<<"你赢了!"<<endl;pscore++;}
else if(x==y)
cout<<"平局!"<<endl;
else
{ cout<<"很遗憾"<<name<<"你输了!"<<endl;cscore++;}
cout<<"\n-----------------------\n"<<endl;
}

void liucheng() //每把三局(流程)============================================================liucheng
{
int p,c,i;
for(i=0;i<3;i++)
{
p=person();
c=computer();
compare(p,c);
}
}

void Game()//==============================================================================Game
{
int n;
cout<<endl<<"==========猜拳游戏=========="<<endl;
cout<<"请输入你的对手!(无双剑姬、霸天剑魔、正义天使)"<<endl;
cin>>pc_name;//不行的话设置为全局变量试试
cout<<"您的对手为"<<pc_name<<endl;
liucheng();
cout<<"比赛成绩:"<<name<<"的得分"<<pscore<<";"<<pc_name<<"得分:"<<cscore<<endl;
}

int main()
{
Menu();//显示菜单
liucheng();
return 0;
}

1.首先定义一个结构体,或者数组;
2.对数组进行排序,再显示;