cout << \是否为党员\while (1){
cin >> p1[i].tpartym; if(isYN(p1[i].tpartym)) break; else
cout<<\格式错误,请重新输入\}
cout << \请输入手机号码\while(1){
cin >> p1[i].phoneNo; if(isNo(p1[i].phoneNo)) break; else
cout<<\格式错误,请重新输入\}
cout << \请输入地址\cin >> p1[i].addr; InitQueue(p1[i]); p1[i].average=0;
//if(!(fp=fopen(\//cout<<\打开文件错误\courses e; e.next=0; while (1){
cout << \请输入课程代号,输0结束\ cin >> e.cNo;
//if(isExitcNo(p1[i],e.cNo))
// cout<<\该课程已存在,请勿重新输入\ //else{
if(strcmp(e.cNo,\
strcpy(e.cname,\原理基础\ else if(strcmp(e.cNo,\ strcpy(e.cname,\数据结构\ else if(strcmp(e.cNo,\ strcpy(e.cname,\数学建模\ else if(strcmp(e.cNo,\ strcpy(e.cname,\微观经济\ else if (strcmp(e.cNo, \ break; else {
cout<<\课程代号出错,请重新输入\ continue; }
cout << \请输入该课程成绩\ cin >> e.degree;
if(exiscNoreassign(p1[i],e.cNo,e.degree)==0) EnQueue(p1[i], e); //} }
InsertFile(p1[i]);
cout << \继续添加\ cout<<\返回\ cin >> a; i++;
} while (a!=0);} break; case 8:{
int a=-1; do{
int flag=0; if(i==0){
cout<<\信息为空,请先创建基本信息\ a=0; } else{
char c[10]; student temp;
cout<<\请输入要删除的学号\ cin>>c;
for(int j=0;j
if(strcmp(p1[j].No,c)==0) { i--;
for(int k=j;k
if(flag==0)
cout<<\该学号不存在或已被删除\ else
reWFile(p1,i);
cout<<\继续删除\ cout<<\返回上层\ cin>>a;
}
}while(a!=0);} break;
case 9:break; defalult:
cout<<\请输入1-9的数字:\ system(\ break; }
system(\ system(\ }while(choice!=9); return 0 ; }
头文件:
typedef struct courses{ char cNo[15]; char cname[20]; char sNo[10]; int degree; courses *next; }courses;
typedef struct student{ char No[10]; char name[10]; char gender[5]; char brithday[8]; char tpartym[5]; char phoneNo[15]; char addr[20]; //courses a; courses *front; courses *rear; int average; }student;
/*typedef struct{ courses *front; courses *rear; }LinkQueue;*/
Status InitQueue(student &Q) {
Q.front=Q.rear=new courses;
Q.front->next=0; return OK; }
Status EnQueue(student &Q,courses e) {
courses *r; r=new courses;
strcpy(r->cNo,e.cNo); strcpy(r->cname,e.cname); r->degree=e.degree; r->next=0;
Q.rear->next=r; Q.rear=r; return OK; }
Status DeQueue(student &Q,courses &e) {
courses *r;
if(Q.front==Q.rear)return ERROR; r=Q.front->next;
strcpy(e.sNo,r->sNo); e.degree=r->degree; Q.front->next=r->next; if(Q.rear=r)
Q.rear=Q.front; delete r; return OK; }
Status GetLine(student Q) {
courses *r;
if(Q.front==Q.rear)
cout<<\课程信息为空,请先输入课程信息\ else{
r=Q.front->next; while(r){
//strcpy(e.cNo,Q.front->next->cNo); //e.degree=Q.front->next->degree; cout< Status CalculateAve(student &Q) { int n=0; courses *r; if(Q.front==Q.rear) return ERROR; r=Q.front->next; Q.average=0; while(r){ Q.average+=r->degree; r=r->next; n++; } Q.average/=n; return OK; } int isExitcNo(student Q,char *cNo) { int flag=0; courses *r; if(Q.front==Q.rear) return ERROR; r=Q.front->next; while(r){ if(strcmp(r->cNo,cNo)==0){ flag=1; break; } r=r->next;} return flag; } int isExistNo(student *p1,char *No,int i=0) { int j=0,flag=0; for(j=0;j if(strcmp(p1[j].No,No)==0) { flag=1; break; } return flag; } int exiscNoreassign(student &Q,char *cNo,int degree){ int flag=0; courses *r; if(Q.front==Q.rear) return ERROR;