C語言實現(xiàn)魔方比賽管理系統(tǒng)_第1頁
C語言實現(xiàn)魔方比賽管理系統(tǒng)_第2頁
C語言實現(xiàn)魔方比賽管理系統(tǒng)_第3頁
C語言實現(xiàn)魔方比賽管理系統(tǒng)_第4頁
C語言實現(xiàn)魔方比賽管理系統(tǒng)_第5頁
已閱讀5頁,還剩13頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

第C語言實現(xiàn)魔方比賽管理系統(tǒng)本文實例為大家分享了C語言實現(xiàn)魔方比賽管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

#includestdio.h

#includestdlib.h

#includestring.h

#defineAVAILABLE0

#defineUNAVAILABLE1

#defineMAXNAME30

#defineCLEAR"cls"

typedefstructmatch{

char*name;

intid;

intcount;

intstatus;

structmatch*next;

}Match;

voidwelcome();

voiderror(char*);

charland();

intplayer();

intusrmanager();

intviewmatch();

intaddmatch();

intmodmatch();

intdelmatch();

voidprintmatch(Match*);

Match*lookup(char*,int);

intjoinmatch();

intfinishmatch();

Match*head=NULL;

intnmatch=0;

//主函數(shù)

intmain(){

welcome();

return0;

voidwelcome(){

printf("*************************歡迎使用魔方比賽管理系統(tǒng)*************************\n");

while(1){

printf("-------------------------------------\n");

printf("請輸入項目前編號執(zhí)行相關(guān)操作:\n");

printf("\n[1]管理員入口\n\n[2]選手入口\n\n[0]退出\n\n");

switch(land()){

case'1':

while(1){

if(usrmanager()){

continue;

}else{

break;

}

}

break;

case'2':

while(1){

if(player()){

continue;

}else{

break;

}

}

break;

case'0':

exit(0);

default:

error("采集項目參數(shù)失敗");

}

}

charland(){

charc,flag;

inti;

while(1){

for(i=0;(c=getchar())!='\n';flag=c,++i)

;

if(i==1){

if(flag=='1'||flag=='2'||flag=='0'){

returnflag;

}

}elseif(i==0){

continue;

}

error("[請輸入命令:1/2/0選擇項目]");

}

return'\0';

voiderror(char*s){

fprintf(stderr,"%s\n",s);

chardostudent(){

charc,flag;

inti;

while(1){

for(i=0;(c=getchar())!='\n';flag=c,++i)

;

if(i==1){

if(flag=='1'||flag=='2'||flag=='3'||flag=='0'){

returnflag;

}

}elseif(i==0){

continue;

}

error("[請輸入命令:1/2/3/0選擇項目]");

}

intplayer(){

printf("-------------------------------------\n");

printf("請輸入項目前編號執(zhí)行相關(guān)操作:\n\n");

printf("[1]報名比賽\n[2]完成比賽\n[3]查看比賽\n");

printf("[0]返回主頁\n");

switch(dostudent()){

case'1':

joinmatch();

break;

case'2':

finishmatch();

break;

case'3':

viewmatch();

break;

case'0':

return0;

default:

error("采集項目參數(shù)失敗");

break;

}

return1;

intjoinmatch(){

system(CLEAR);

charsname[MAXNAME];

printf("搜索比賽:\n");

scanf("%s",sname);

getchar();

Match*bp;

char*namep=NULL;

if((bp=lookup(namep=strdup(sname),0))==NULL){

printf("比賽%s不存在\n",namep);

fflush(stdin);

return-1;

}else{

printmatch(bp);

if(!bp-status){

printf("參加比賽:YN\n");

}else{

printf("比賽進(jìn)行中\(zhòng)n");

return0;

}

while(1){

charc='\0';

scanf("%c",

getchar();

if(!(c=='Y'||c=='y'||c=='N'||c=='n')){

fflush(stdin);

error("指令無效");

continue;

}

if(c=='Y'||c=='y'){

--bp-count-1printf("成功\n"):printf("失敗\n");

if(!bp-count){

bp-status=UNAVAILABLE;

}

returnbp-

}else{

return0;

}

}

}

return-1;

intfinishmatch(){

system(CLEAR);

charsname[MAXNAME];

printf("完成比賽:\n");

scanf("%s",sname);

getchar();

Match*bp;

char*namep;

if((bp=lookup(namep=strdup(sname),0))==NULL){

fflush(stdin);

printf("此賽事沒有注冊\n");

return-1;

}else{

printmatch(bp);

printf("完成比賽:YN\n");

while(1){

charc='\0';

scanf("%c",

getchar();

if(!(c=='Y'||c=='y'||c=='N'||c=='n')){

fflush(stdin);

error("指令無效");

}elseif(c=='Y'||c=='y'){

bp-count++0:(bp-status=AVAILABLE);

printf("成功\n");

returnbp-

}else{

return0;

}

}

}

return-1;

chardomanager(){

charc,flag;

inti;

while(1){

for(i=0;(c=getchar())!='\n';flag=c,++i)

;

if(i==1){

if(flag=='1'||flag=='2'||flag=='3'||flag=='4'||flag=='0'){

returnflag;

}

}elseif(i==0){

continue;

}

error("[請輸入命令:1/2/3/4/0選擇項目]");

}

return'\0';

intusrmanager(){

printf("-------------------------------------\n");

printf("請輸入項目前編號執(zhí)行相關(guān)操作:\n\n");

printf("[1]查看比賽項目\n[2]添加新項目\n[3]修改已有項目\n[4]刪除比賽項目\n");

printf("[0]返回主頁\n");

switch(domanager()){

case'1':

viewmatch();

break;

case'2':

addmatch();

break;

case'3':

modmatch();

break;

case'4':

delmatch();

break;

case'0':

return0;

default:

error("采集項目參數(shù)失敗");

break;

}

return1;

intviewmatch(){

system(CLEAR);

Match*bp;

for(bp=head;bp!=NULL;bp=bp-next){

printmatch(bp);

}

if(nmatch){

returnnmatch;

}else{

printf("比賽沒有這個項目\n");

return0;

}

return-1;

voidprintmatch(Match*bp){

printf("項目編號:%d\n",bp-

printf("項目名:%s\n",bp-name);

printf("項目狀態(tài):%s\n",bp-status"未開始":"開始");

intaddmatch(){

system(CLEAR);

charsname[MAXNAME];

intid,count;

char*namep;

while(1){

id=0;

count=0;

namep=NULL;

printf("請輸入比賽名:\n");

scanf("%s",sname);

getchar();

printf("請輸入小于1000的比賽編號:\n");

scanf("%d",id);

getchar();

if(!(id0id1000)){

error("輸入編號不符合要求");

fflush(stdin);

continue;

}

printf("請輸入小于50的比賽選手?jǐn)?shù)量:\n");

scanf("%d",count);

getchar();

if(!(count0count50)){

error("輸入數(shù)目不符合要求");

fflush(stdin);

continue;

}

Match*bp;

if((bp=lookup(namep=strdup(sname),id))==NULL){

bp=(Match*)malloc(sizeof(Match));

if(bp==NULL||(bp-name=namep)==NULL){

error("添加比賽失敗");

fflush(stdin);

continue;

}

bp-id=id;

bp-count=count;

bp-status=AVAILABLE;

++nmatch;

bp-next=head;

head=bp;

printf("比賽%s注冊成功\n",sname);

returnid;

}else{

fflush(stdin);

error("項目名或編號已經(jīng)被占用");

}

}

return-1;

Match*lookup(char*s,intid){

Match*bp;

for(bp=head;bp!=NULL;bp=bp-next){

if(id==bp-id||strcmp(s,bp-name)==0){

returnbp;

}

}

returnNULL;

intmodmatch(){

system(CLEAR);

Match*bp=NULL;

while(1){

intid=0;

printf("請輸入要修改信息的項目編號:\n");

scanf("%d",id);

getchar();

if(!(id0id1000)){

fflush(stdin);

error("項目編號不符合要求");

continue;

}

if((bp=lookup("",id))!=NULL){

printf("以下為要修改的項目的現(xiàn)有信息:\n");

printmatch(bp);

printf("[1]修改項目名\n[2]修改比賽選手?jǐn)?shù)量\n[3]修改項目狀態(tài)\n[0]放棄修改\n");

while(1){

inti;

scanf("%d",

getchar();

if(!(i==1||i==2||i==3||i==0)){

fflush(stdin);

error("輸入項目前編號選擇相關(guān)項目");

continue;

}

switch(i){

case1:

while(1){

charnewname[MAXNAME],*namep;

printf("項目名:\n");

scanf("%s",newname);

getchar();

if((lookup(namep=strdup(newname),0))!=NULL){

fflush(stdin);

error("項目名已存在");

continue;

}

if((bp-name=namep)!=NULL){

printf("修改成功\n");

returnid;

}

}

break;

case2:

while(1){

intbnum;

printf("輸入比賽數(shù)量:\n");

scanf("%d",bnum);

getchar();

if(!(bnum0||bnum1000)){

fflush(stdin);

error("數(shù)目不符合要求");

continue;

}

bp-count=bnum;

printf("修改成功\n");

returnid;

}

break;

case3:

while(1){

charc;

intstatus;

status=bp-status;

status==AVAILABLEprintf("修改狀態(tài)為[未開始]:YN\n"):printf("修改狀態(tài)為[開始]:YN\n");

scanf("%c",

getchar();

if(!(c=='Y'||c=='y'||c=='N'||c=='n')){

fflush(stdin);

error("指令無效");

continue;

}

if(c=='Y'||c=='y'){

status==AVAILABLEbp-status=UNAVAILABLE:(bp-status=AVAILABLE);

printf("修改成功\n");

returnid;

}else{

printf("放棄修改\n");

return0;

}

}

break;

case0:

return0;

default:

error("獲取參數(shù)失敗");

break;

}

}

}else{

printf("沒有此比賽\n");

return0;

}

}

return-1;

intdelmatch(){

system(CLEAR);

Match*bp,*f

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論