📄 joseph.c
字号:
#include <stdio.h>#define CHAIN_COMMON#include "group_common.h"int main(){ struct chain_init op_round; struct chain_cur round; int st_num=0; int M=0; int i; st_num=0; M=0; i=0; printf("What the M?:"); scanf("%d",&M); printf("How many students will you enter?:"); scanf("%d",&st_num); op_round=chain_Create(); round=chain_Curcreate(&op_round); /*输入学生*/ for(;;) { struct st_info tmp_struct; if(i>=st_num)break; printf("\nEnter the name of student %d:",i+1); scanf("%s",tmp_struct.st_name); printf("\nEnter his/her M:"); scanf("%d",&(tmp_struct.st_M)); chain_Append(tmp_struct,&round); i++; }; /*开始计算*/ chain_First(&round); i=1; for(;;) { if(i==M) { struct st_info tmp_struct=chain_Get(&round); printf("One student had been selected,his/her name is %s,the M is %d,the i is %d\n",tmp_struct.st_name,M,i); M=tmp_struct.st_M; chain_Remove(&round); if(chain_Length(&round)==1) { chain_First(&round); tmp_struct=chain_Get(&round); printf("One student had been selected,his/her name is %s,the M is %d,the i is %d\n",tmp_struct.st_name,M,i); break; }; if(chain_Eof(&round)) { chain_First(&round); } else { chain_Next(&round); }; i=1; continue; }; i++; if(chain_Eof(&round)) { chain_First(&round); } else { chain_Next(&round); }; }; printf("Finish!"); return 0; };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -