#include<stdlib.h>
#include<string.h>
#define N 100 /*定义最大用户量*/
#define M 20 /*定义最大参赛选手量*/
typedef struct user /**/
{ char name[20]; /*定义用户名*/
int number[11]; /*定义用户手机号*/
int times; /*用户投票次数*/
int yitimes; /*已投票次数*/
}USE;
typedef struct player /**/
{ char minzi[20]; /*定义选手名 */
int shouji[11]; /*定义选手手机号*/
int score; /*选手分数*/
int turn; /*选手排名*/
double percent; /*百分比*/
}PLAYE;
/*以下为菜单页面板块*/
void menu() /*顶层菜单*/
{
printf("******** 1. 登录 ************\n");
printf("******** 2. 注册 ************\n");
printf("******** 3. 信息公布 ********\n");
printf("******** 0. 退出 ************\n");
}
void denglumenu() /*登录菜单*/
{
printf("******** 1. 投票用户登录 ********\n");
printf("******** 2. 管理员窗口 **********\n");
printf("******** 0. 退出 ********\n");
}
void dengluymenu() /*用户选项菜单*/
{ printf("******** 1. 查询参赛选手 ********\n");
printf("******** 2. 投票 ********\n");
printf("******** 0. 退出 ********\n");
}
void guanlimenu() /*管理员菜单*/
{
printf("******** 1. 查询参赛选手 ****************\n");
printf("******** 2. 修改投票次数 ****************\n");
printf("******** 3. 审核(删除)参赛选手 ********\n");
printf("******** 4. 是否公布信息 *****************\n");
printf("******** 0. 退出 ************************\n");
}
void zuchemenu() /*注册菜单*/
{
printf("******** 1. 投票用户注册 ********\n");
printf("******** 2. 参赛选手注册 ********\n");
printf("******** 0. 退出 ********\n");
}
/*以下为文本的读出与输入板块*/
int ureadFile(USE *us) /*格式化输出文本中的投票用户数据*/
{ FILE *ufp=NULL;
int q=0;
if(!fopen_s(&ufp,"user.txt","r")) /*以读方式打开指定文件并判断*/
{
printf("file does not exist,create it first:\n"); /*若打开失败输出提示信息*/
fclose(ufp);
return 0; /*返回0条记录条数*/
}
else /*成功打开文件并读入指定数组*/
{fscanf_s(ufp,"%s%d%d%d",us[q].name,&us[q].number,&us[q].times,&us[q].yitimes); /*读出第一条记录*/
while(!feof(ufp))
{
q++;
fscanf_s(ufp,"%s%d%d%d",us[q].name,&us[q].number,&us[q].times,&us[q].yitimes); /*再读出下一条记录*/
}
fclose(ufp); /*关闭文件*/
return q; /*返回记录条数*/
}
}
void usaveFile(USE *us,int n) /*把投票用户数据格式化写入文本*/
{ FILE *fp = NULL;
int q;
if(!fopen_s(&fp,"user.txt","w")) /*以写方式打开指定文件*/
printf("can not open file !\n"); /*若打开失败,输出提示信息*/
else
{
for(q=0;q<n-1;q++)
fprintf(fp,"%10s%6d%6d%6d\n",us[q].name,us[q].number,us[q].times,us[q].yitimes);
}
fclose(fp); /*关闭文件*/
}
int preadFile(PLAYE *play) /*格式化读出参赛选手数据*/
{
FILE *fq=NULL;
int q=0;
if(!fopen_s(&fq,"player.txt","r")) /*以读方式打开指定文件并判断*/
{
printf("file does not exist,create it first:\n"); /*若打开失败输出提示信息*/
return 0; /*然后返回0条记录条数*/
fclose(fq); /*关闭文件*/
}
else
{
fscanf_s(fq,"%s%d%d%d%lf",play[q].minzi,&play[q].shouji,&play[q].score,&play[q].turn,&play[q].percent); /*读出第一条记录*/
while(!feof(fq)) /*文件未结束时循环*/
{
q++;
fscanf_s(fq,"%s%d%d%d%.2lf",play[q].minzi,&play[q].shouji,&play[q].score,&play[q].turn,&play[q].percent); /*再读出下一条记录*/
}
fclose(fq); /*关闭文件*/
return q; /*返回记录条数*/
}
}
void psaveFile(PLAYE *play,int n) /*将参赛选手户数据格式化输入文本中*/
{ FILE *pfq=NULL;
int q;
if(fopen_s(&pfq,"player.txt","w")) /*以写方式打开指定文件*/
{
printf("打开失败!\n"); /*若打开失败,输出提示信息*/
exit(0); /*然后退出*/
}
else
{
for(q=0;q<n-1;q++)
fprintf(pfq,"%10s%6d%6d%6d%6.2lf\n",play[q].minzi,play[q].shouji,play[q].score,play[q].turn,play[q].percent); /*写入每条数据*/
}
fclose(pfq); /*关闭文件*/
}
int greadFile() /*格式化读出信息公布文本的数据*/
{ int ga; /*接收文本中数字的参数*/
FILE *gre=NULL;
if(fopen_s(&gre,"information.txt","w")) /*以写方式打开指定文件*/
{
printf("打开失败!\n"); /*若打开失败,输出提示信息*/
exit(0); /*然后退出*/
}
fscanf_s(gre,"%d",&ga);
fclose(gre);
if(ga==1)
return 1;
else
return 0; /*判断是否公布信息*/
}
void gsaveFile(int n) /*将管理员是否允许信息公布的相关数格式化写入文本*/
{
FILE *sav=NULL;
if(fopen_s(&sav,"information.txt","w")) /*以写方式打开指定文件*/
{
printf("打开失败!\n"); /*若打开失败,输出提示信息*/
exit(0); /*然后退出*/
}
fprintf_s(sav,"%d",&n);
fclose(sav);
}
/*最低级的程序板块或者计算板块*/
void surchp(PLAYE *play) /*查询和显示参赛选手信息*/
{ int i=0,num;
num=preadFile(play); /*play读取了文本的全部信息*/
printf("***选手名***手机号***得分***排名***百分比***");
for (i=0; i<num; i++)
printf("%-6s %d %d %d %.2f\n",play[i].minzi,play[i].shouji,play[i].score,play[i].turn,play[i].percent);
psaveFile(play,num); /*返回数据到文本*/
}
void surchu(USE *us) /*查询和显示用户信息*/
{ int i=0,num;
num=ureadFile(us); /*play读取了文本的全部信息*/
printf("***选手名***手机号***投票数***已投票数***");
for (i=0; i<num; i++)
printf( "%-6s %d %d %d\n",us[i].name,us[i].number,us[i].times,us[i].yitimes);
usaveFile(us,num); /*返回数据到文本*/
}
void ucreat(USE *us) /*用户注册*/
{int i;
i=ureadFile(us); /*用第i+1个数组储存新注册用户信息*/
printf("输入你的用户名");
scanf_s("%s",&us[i].name);
printf("输入你的手机号");
scanf_s("%d",&us[i].number);
us[i].times=1;
us[i].yitimes=0;
usaveFile(us,i+1); /*返回全部数据到文本*/
}
void pcreat(PLAYE *play) /*参赛选手注册*/
{
int i;
i=preadFile(play); /*用第i+1个数组储存新注册用户信息*/
printf("输入你的用户名");
scanf_s("%s",&play[i].minzi);
printf("输入你的手机号");
scanf_s("%d",&play[i].shouji);
play[i].score=0;
play[i].turn=1;
play[i].percent=1; /*得分默认为0,名次默认为1,百分比默认为1*/
i=i+1; /*数据条数*/
psaveFile(play,i); /*返回全部数据到文本*/
}
void rank(PLAYE *play) /*参赛选手排名*/
{ int i,j,k,n;
n=preadFile(play);
for (i=0;i<n-1;i++)
{ k=i;
for (j=i+1;j<n;j++)
if(play[j].score>play[k].score)
k=j;
if(k!=i)
{ play[n]=play[i]; /*用第n+1个play作为中转*/
play[i]=play[k];
play[k]=play[n];
}
}
play[0].turn=1;
for (i=1;i<n; i++)
{
if(play[i].score==play[i-1].score)
play[i].turn=play[i-1].turn;
else
play[i].turn=i+1;
}
psaveFile(play,n);
}
void jishuan(PLAYE *play) /*百分比计算*/
{int n,i,he=0;
n=preadFile(play);
for (i=0;i<n-1;i++)
{
he+=play[i].score; /*算出总共票数*/
}
for (i=0;i<n-1;i++)
{
play[i].percent=(play[i].score)/he;
}
psaveFile(play,n);
}
void deleteStu(PLAYE *play) /*删除不合格参赛选手*/
{
int i,j,n;
char NM[20];
n=preadFile(play);
printf("请输入待删除参赛选手名字");
scanf_s("%s",&NM);
for (i=0;i<n;i++)
{if (play[i].minzi==NM)
break;
}
if (i==n)
printf("没有该人!\n");
else {for (j=i; j<n-1; j++)
play[j]=play[j+1];
n--;
psaveFile(play,n);
}
}
void change(USE *us) /*修改用户投票次数*/
{ int n,i,k;
char TP[11];
n=ureadFile(us);
surchu(us);
printf("输入想修改投票次数用户的名字");
scanf_s("%s",&TP);
for (i=0;i<n-1;i++)
{if(us[i].name==TP)
break;
}
printf("输入想修改的次数");
scanf_s("%d",&k);
if(k>=us[i].times)
us[i].times=k;
else
printf("修改次数小于原有次数,修改无效");
}
/*三级选择函数*/
void udlm(USE *us,PLAYE *play) /*用户登录函数*/
{ int choice;
const char *a; /*用来储存刚登陆用户的姓名,*/
int i,b[11],c=0;
int k,j,n,m;
char NH[20];
n=preadFile(play);
m=ureadFile(us);
printf("输入你的用户名");
scanf_s("%s",&a);
printf("输入你的手机号");
scanf_s("%d",&b);
for (i=0; i<m; i++)
{
if((a==us[i].name)&&(b==us[i].number)) /*对比用户登录的信息是否正确*/
c=c+1;
}
if(c>=1)
c=1;
else
c=0;
if(c==1)
{
do
{ dengluymenu();
printf("输入对应选项号码:\n");
scanf_s("%d",&choice);
switch(choice)
{ case 1: surchp(play);break;
case 2:
{
printf("输入想投票参赛选手名字");
scanf_s("%s",&NH);
for (k=0;k<m-1;k++) /*找到登录的对应用户*/
{
if(a==us[k].name) /*找到登录用户对应的数组*/
break;
}
if (us[k].times>us[k].yitimes)/*确让用户是否有投票次数*/
{
for (j=0;j<n-1;j++)
{
if(play[j].minzi==NH) /*找到对应参赛选手*/
break;
}
play[j].score++;
us[k].yitimes++;
psaveFile(play,n);
usaveFile(us,m);
}
else printf("已达最大投票次数,不能再投");
}; break;
case 0: break;
}
}while(choice);
}
}
void gly(USE *us,PLAYE *play) /*管理员选项函数*/
{ int ch;
int t,gonbu;
do
{ guanlimenu(); /*显示对应的菜单*/
printf("输入对应选项号码:\n");
scanf_s("%d",&ch);
switch(ch)
{ case 1: surchp(play); break;
case 2: change(us); break;
case 3: deleteStu(play); break;
case 4: {
printf("是否公布信息\n");
printf("1.公布信息\n");
printf("0.不公布或撤回已公布信息\n");
scanf_s("%d",&t);
if(t==1)
{gonbu=greadFile();
if(gonbu==t)
printf("信息已公布,前往首页查看");
}
else
printf("信息已取消公布");
gsaveFile(t);
};
break;
case 0: break;
}
}while(ch);
}
void zc(USE *us,PLAYE *play) /*注册选项函数*/
{ int choic;
do
{ zuchemenu(); /*显示对应的菜单*/
printf("输入对应选项号码:\n");
scanf_s("%d",&choic);
switch(choic)
{ case 1: ucreat(us); break;
case 2: pcreat(play); break;
case 0: break;
}
}while(choic);
}
/*二级选择函数*/
void dl(USE *us,PLAYE *play) /*登录选项函数*/
{ int xuanzi,m;
do
{ denglumenu();
printf("输入对应选项号码:\n");
scanf_s("%d",&xuanzi);
switch(xuanzi)
{ case 1: udlm(us,play); break;
case 2:
{ printf("请输入管理员特权号");
scanf_s("%d",&m);
if(m==20200421)
{gly(us,play);
}
else printf("特权号错误,已退出");
}; break;
case 0: break;
}
}while(xuanzi);
}
int main()
{ USE us[N];
PLAYE play[M];
int xz;
menu();
printf("输入对应选项号码:\n");
scanf_s("%d",&xz);
do
{
switch(xz)
{
case 1 : dl(us,play); break;
case 2 : {
zc(us,play);
dl(us,play);
}
break;
case 3: {xz=greadFile();
if(xz==1)
{ rank(play);
surchp(play);}
else printf("信息未公布");
gsaveFile(xz);
}
break;
case 0: break;
}
}while(xz);
return 0;
}
ureadFile 里面的 us 指针没有分配空间
主要是打开文件的判断问题,给你改了一下:
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#define N 100 /*定义最大用户量*/
#define M 20 /*定义最大参赛选手量*/
typedef struct user /**/
{
char name[20]; /*定义用户名*/
int number[11]; /*定义用户手机号*/
int times; /*用户投票次数*/
int yitimes; /*已投票次数*/
}USE;
typedef struct player /**/
{
char minzi[20]; /*定义选手名 */
int shouji[11]; /*定义选手手机号*/
int score; /*选手分数*/
int turn; /*选手排名*/
double percent; /*百分比*/
}PLAYE;
/*以下为菜单页面板块*/
void menu() /*顶层菜单*/
{
printf("******** 1. 登录 ************\n");
printf("******** 2. 注册 ************\n");
printf("******** 3. 信息公布 ********\n");
printf("******** 0. 退出 ************\n");
}
void denglumenu() /*登录菜单*/
{
printf("******** 1. 投票用户登录 ********\n");
printf("******** 2. 管理员窗口 **********\n");
printf("******** 0. 退出 ********\n");
}
void dengluymenu() /*用户选项菜单*/
{
printf("******** 1. 查询参赛选手 ********\n");
printf("******** 2. 投票 ********\n");
printf("******** 0. 退出 ********\n");
}
void guanlimenu() /*管理员菜单*/
{
printf("******** 1. 查询参赛选手 ****************\n");
printf("******** 2. 修改投票次数 ****************\n");
printf("******** 3. 审核(删除)参赛选手 ********\n");
printf("******** 4. 是否公布信息 *****************\n");
printf("******** 0. 退出 ************************\n");
}
void zuchemenu() /*注册菜单*/
{
printf("******** 1. 投票用户注册 ********\n");
printf("******** 2. 参赛选手注册 ********\n");
printf("******** 0. 退出 ********\n");
}
/*以下为文本的读出与输入板块*/
int ureadFile(USE *us) /*格式化输出文本中的投票用户数据*/
{
FILE *ufp = NULL;
int q = 0;
if (fopen_s(&ufp, "user.txt", "r")) /*以读方式打开指定文件并判断*/
{
printf("file does not exist,create it first:\n"); /*若打开失败输出提示信息*/
//fclose(ufp);
return 0; /*返回0条记录条数*/
}
else /*成功打开文件并读入指定数组*/
{
fscanf_s(ufp, "%s%d%d%d", us[q].name, &us[q].number, &us[q].times, &us[q].yitimes); /*读出第一条记录*/
while (!feof(ufp))
{
q++;
fscanf_s(ufp, "%s%d%d%d", us[q].name, &us[q].number, &us[q].times, &us[q].yitimes); /*再读出下一条记录*/
}
fclose(ufp); /*关闭文件*/
return q; /*返回记录条数*/
}
}
void usaveFile(USE *us, int n) /*把投票用户数据格式化写入文本*/
{
FILE *fp = NULL;
int q;
if (fopen_s(&fp, "user.txt", "w")) /*以写方式打开指定文件*/
printf("can not open file !\n"); /*若打开失败,输出提示信息*/
else
{
for (q = 0; q < n - 1; q++)
fprintf(fp, "%10s%6d%6d%6d\n", us[q].name, us[q].number, us[q].times, us[q].yitimes);
fclose(fp);
}
/*关闭文件*/
}
int preadFile(PLAYE *play) /*格式化读出参赛选手数据*/
{
FILE *fq = NULL;
int q = 0;
if (fopen_s(&fq, "player.txt", "r")) /*以读方式打开指定文件并判断*/
{
printf("file does not exist,create it first:\n"); /*若打开失败输出提示信息*/
return 0; /*然后返回0条记录条数*/
}
else
{
fscanf_s(fq, "%s%d%d%d%lf", play[q].minzi, &play[q].shouji, &play[q].score, &play[q].turn, &play[q].percent); /*读出第一条记录*/
while (!feof(fq)) /*文件未结束时循环*/
{
q++;
fscanf_s(fq, "%s%d%d%d%.2lf", play[q].minzi, &play[q].shouji, &play[q].score, &play[q].turn, &play[q].percent); /*再读出下一条记录*/
}
fclose(fq); /*关闭文件*/
return q; /*返回记录条数*/
}
}
void psaveFile(PLAYE *play, int n) /*将参赛选手户数据格式化输入文本中*/
{
FILE *pfq = NULL;
int q;
if (fopen_s(&pfq, "player.txt", "w")) /*以写方式打开指定文件*/
{
printf("打开失败!\n"); /*若打开失败,输出提示信息*/
exit(0); /*然后退出*/
}
else
{
for (q = 0; q < n - 1; q++)
fprintf(pfq, "%10s%6d%6d%6d%6.2lf\n", play[q].minzi, play[q].shouji, play[q].score, play[q].turn, play[q].percent); /*写入每条数据*/
}
fclose(pfq); /*关闭文件*/
}
int greadFile() /*格式化读出信息公布文本的数据*/
{
int ga; /*接收文本中数字的参数*/
FILE *gre = NULL;
if (fopen_s(&gre, "information.txt", "w")) /*以写方式打开指定文件*/
{
printf("打开失败!\n"); /*若打开失败,输出提示信息*/
exit(0); /*然后退出*/
}
fscanf_s(gre, "%d", &ga);
fclose(gre);
if (ga == 1)
return 1;
else
return 0; /*判断是否公布信息*/
}
void gsaveFile(int n) /*将管理员是否允许信息公布的相关数格式化写入文本*/
{
FILE *sav = NULL;
if (fopen_s(&sav, "information.txt", "w")) /*以写方式打开指定文件*/
{
printf("打开失败!\n"); /*若打开失败,输出提示信息*/
exit(0); /*然后退出*/
}
fprintf_s(sav, "%d", &n);
fclose(sav);
}
/*最低级的程序板块或者计算板块*/
void surchp(PLAYE *play) /*查询和显示参赛选手信息*/
{
int i = 0, num;
num = preadFile(play); /*play读取了文本的全部信息*/
printf("***选手名***手机号***得分***排名***百分比***");
for (i = 0; i < num; i++)
printf("%-6s %d %d %d %.2f\n", play[i].minzi, play[i].shouji, play[i].score, play[i].turn, play[i].percent);
psaveFile(play, num); /*返回数据到文本*/
}
void surchu(USE *us) /*查询和显示用户信息*/
{
int i = 0, num;
num = ureadFile(us); /*play读取了文本的全部信息*/
printf("***选手名***手机号***投票数***已投票数***");
for (i = 0; i < num; i++)
printf("%-6s %d %d %d\n", us[i].name, us[i].number, us[i].times, us[i].yitimes);
usaveFile(us, num); /*返回数据到文本*/
}
void ucreat(USE *us) /*用户注册*/
{
int i;
i = ureadFile(us); /*用第i+1个数组储存新注册用户信息*/
printf("输入你的用户名");
scanf_s("%s", &us[i].name);
printf("输入你的手机号");
scanf_s("%d", &us[i].number);
us[i].times = 1;
us[i].yitimes = 0;
usaveFile(us, i + 1); /*返回全部数据到文本*/
}
void pcreat(PLAYE *play) /*参赛选手注册*/
{
int i;
i = preadFile(play); /*用第i+1个数组储存新注册用户信息*/
printf("输入你的用户名");
scanf_s("%s", &play[i].minzi);
printf("输入你的手机号");
scanf_s("%d", &play[i].shouji);
play[i].score = 0;
play[i].turn = 1;
play[i].percent = 1; /*得分默认为0,名次默认为1,百分比默认为1*/
i = i + 1; /*数据条数*/
psaveFile(play, i); /*返回全部数据到文本*/
}
void rank(PLAYE *play) /*参赛选手排名*/
{
int i, j, k, n;
n = preadFile(play);
for (i = 0; i < n - 1; i++)
{
k = i;
for (j = i + 1; j<n; j++)
if (play[j].score>play[k].score)
k = j;
if (k != i)
{
play[n] = play[i]; /*用第n+1个play作为中转*/
play[i] = play[k];
play[k] = play[n];
}
}
play[0].turn = 1;
for (i = 1; i < n; i++)
{
if (play[i].score == play[i - 1].score)
play[i].turn = play[i - 1].turn;
else
play[i].turn = i + 1;
}
psaveFile(play, n);
}
void jishuan(PLAYE *play) /*百分比计算*/
{
int n, i, he = 0;
n = preadFile(play);
for (i = 0; i < n - 1; i++)
{
he += play[i].score; /*算出总共票数*/
}
for (i = 0; i < n - 1; i++)
{
play[i].percent = (play[i].score) / he;
}
psaveFile(play, n);
}
void deleteStu(PLAYE *play) /*删除不合格参赛选手*/
{
int i, j, n;
char NM[20];
n = preadFile(play);
printf("请输入待删除参赛选手名字");
scanf_s("%s", &NM);
for (i = 0; i < n; i++)
{
if (play[i].minzi == NM)
break;
}
if (i == n)
printf("没有该人!\n");
else {
for (j = i; j < n - 1; j++)
play[j] = play[j + 1];
n--;
psaveFile(play, n);
}
}
void change(USE *us) /*修改用户投票次数*/
{
int n, i, k;
char TP[11];
n = ureadFile(us);
surchu(us);
printf("输入想修改投票次数用户的名字");
scanf_s("%s", &TP);
for (i = 0; i < n - 1; i++)
{
if (us[i].name == TP)
break;
}
printf("输入想修改的次数");
scanf_s("%d", &k);
if (k >= us[i].times)
us[i].times = k;
else
printf("修改次数小于原有次数,修改无效");
}
/*三级选择函数*/
void udlm(USE *us, PLAYE *play) /*用户登录函数*/
{
int choice;
const char *a; /*用来储存刚登陆用户的姓名,*/
int i, b[11], c = 0;
int k, j, n, m;
char NH[20];
n = preadFile(play);
m = ureadFile(us);
printf("输入你的用户名");
scanf_s("%s", &a);
printf("输入你的手机号");
scanf_s("%d", &b);
for (i = 0; i < m; i++)
{
if ((a == us[i].name) && (b == us[i].number)) /*对比用户登录的信息是否正确*/
c = c + 1;
}
if (c >= 1)
c = 1;
else
c = 0;
if (c == 1)
{
do
{
dengluymenu();
printf("输入对应选项号码:\n");
scanf_s("%d", &choice);
switch (choice)
{
case 1: surchp(play); break;
case 2:
{
printf("输入想投票参赛选手名字");
scanf_s("%s", &NH);
for (k = 0; k<m - 1; k++) /*找到登录的对应用户*/
{
if (a == us[k].name) /*找到登录用户对应的数组*/
break;
}
if (us[k].times>us[k].yitimes)/*确让用户是否有投票次数*/
{
for (j = 0; j < n - 1; j++)
{
if (play[j].minzi == NH) /*找到对应参赛选手*/
break;
}
play[j].score++;
us[k].yitimes++;
psaveFile(play, n);
usaveFile(us, m);
}
else printf("已达最大投票次数,不能再投");
}; break;
case 0: break;
}
} while (choice);
}
}
void gly(USE *us, PLAYE *play) /*管理员选项函数*/
{
int ch;
int t, gonbu;
do
{
guanlimenu(); /*显示对应的菜单*/
printf("输入对应选项号码:\n");
scanf_s("%d", &ch);
switch (ch)
{
case 1: surchp(play); break;
case 2: change(us); break;
case 3: deleteStu(play); break;
case 4: {
printf("是否公布信息\n");
printf("1.公布信息\n");
printf("0.不公布或撤回已公布信息\n");
scanf_s("%d", &t);
if (t == 1)
{
gonbu = greadFile();
if (gonbu == t)
printf("信息已公布,前往首页查看");
}
else
printf("信息已取消公布");
gsaveFile(t);
};
break;
case 0: break;
}
} while (ch);
}
void zc(USE *us, PLAYE *play) /*注册选项函数*/
{
int choic;
do
{
zuchemenu(); /*显示对应的菜单*/
printf("输入对应选项号码:\n");
scanf_s("%d", &choic);
switch (choic)
{
case 1: ucreat(us); break;
case 2: pcreat(play); break;
case 0: break;
}
} while (choic);
}
/*二级选择函数*/
void dl(USE *us, PLAYE *play) /*登录选项函数*/
{
int xuanzi, m;
do
{
denglumenu();
printf("输入对应选项号码:\n");
scanf_s("%d", &xuanzi);
switch (xuanzi)
{
case 1: udlm(us, play); break;
case 2:
{ printf("请输入管理员特权号");
scanf_s("%d", &m);
if (m == 20200421)
{
gly(us, play);
}
else printf("特权号错误,已退出");
}; break;
case 0: break;
}
} while (xuanzi);
}
int main()
{
USE us[N];
PLAYE play[M];
int xz;
menu();
printf("输入对应选项号码:\n");
scanf_s("%d", &xz);
do
{
switch (xz)
{
case 1: dl(us, play); break;
case 2: {
zc(us, play);
dl(us, play);
}
break;
case 3: {xz = greadFile();
if (xz == 1)
{
rank(play);
surchp(play);
}
else printf("信息未公布");
gsaveFile(xz);
}
break;
case 0: break;
}
} while (xz);
return 0;
}