宫斗群求职表求大触原创

为了账号安全,请及时绑定邮箱和手机
求助大触来帮帮忙解答一下!!!
#include &stdio.h&#include &stdlib.h&#include &string.h&typedef struct subjects{ char name[20]; char kind[10]; struct subjects *}SUB; SUB *create_form(){ SUB *head,*tail,*p; int num,stime, int etime,score, char name[20],kind[10]; int size=sizeof(SUB); head=tail=NULL; printf("输入选修课程信息:\n"); scanf("%d %s %s %d %d %d %d %d",&num,&name,&kind,&stime,&ttime,&etime,&score,&term); while(num!=0){
p=(SUB *)malloc(size);
strcpy(p-&name,name);
strcpy(p-&kind,kind);
p-&term= if(head==NULL)
head=p; else
tail-&next=p; tail=p; scanf("%d %s %s %d %d %d %d %d",&num,&name,&kind,&stime,&ttime,&etime,&score,&term); } tail-&next=NULL;} void savefile(SUB *head){ SUB *p; FILE * fp=fopen("subjects.txt","w"); fprintf(fp,"课程编号
实验或上机学时
开课学期\n"); for(p=p;p=p-&next)
fprintf(fp,"%5d%12s%9s%9d%9d%11d%11d%7d\n",p-&num,p-&name,p-&kind,p-&stime,p-&ttime,p-&etime,p-&score,p-&term); fclose(fp);} void savefileadd(SUB *head){ SUB *p; FILE * fp=fopen("subjectsadd.txt","w"); fprintf(fp,"课程编号
实验或上机学时
开课学期\n"); for(p=p;p=p-&next)
fprintf(fp,"%5d%12s%9s%9d%9d%11d%11d%7d\n",p-&num,p-&name,p-&kind,p-&stime,p-&ttime,p-&etime,p-&score,p-&term); fclose(fp);} void savefiledel(SUB *head){ SUB *p; FILE * fp=fopen("subjectsdel.txt","w"); fprintf(fp,"课程编号
实验或上机学时
开课学期\n"); for(p=p;p=p-&next)
fprintf(fp,"%5d%12s%9s%9d%9d%11d%11d%7d\n",p-&num,p-&name,p-&kind,p-&stime,p-&ttime,p-&etime,p-&score,p-&term); fclose(fp);} void prin(SUB *head){ SUB * if(head==NULL){
printf("没有此门课程记录!\n"); } printf("课程编号
实践或上机学时
开课学期\n"); for(ptr=ptr=ptr-&next)
printf("%5d%12s%9s%9d%9d%11d%11d%7d\n",ptr-&num,ptr-&name,ptr-&kind,ptr-&stime,ptr-&ttime,ptr-&etime,ptr-&score,ptr-&term);}void search(SUB *head){ int a, int t=1; char type[10]; char ch='a',ch1; SUB *
while(ch!=' '){
printf("若要按课程性质查找请输入1,若要按学分查找请输入2:\n");
scanf("%d",&a);
switch(a){
case 1:printf("请输入要查找的课程的性质:\n");
scanf("%s",type);
printf("课程编号
实践或上机学时
开课学期\n");
for(ptr=ptr=ptr-&next)
if(strcmp(type,ptr-&kind)==0){
printf("%5d%12s%9s%9d%9d%11d%11d%7d\n",ptr-&num,ptr-&name,ptr-&kind,ptr-&stime,ptr-&ttime,ptr-&etime,ptr-&score,ptr-&term);
if(t) printf("未找到!\n");
case 2:printf("输入要查找的课程的学分\n");
scanf("%d",&num);
printf("课程编号
实践或上机学时
开课学期\n");
for(ptr=ptr=ptr-&next)
if(ptr-&score==num){
printf("%5d%12s%9s%9d%9d%11d%11d%7d\n",ptr-&num,ptr-&name,ptr-&kind,ptr-&stime,ptr-&ttime,ptr-&etime,ptr-&score,ptr-&term);
if(t) printf("未找到!\n");
} printf("继续查找请按回车键,结束请按空格键:\n"); ch1=getchar();
//将回车键赋给CH1,否则CASE里面最后输入的回车键会赋给CH,因此用CH1填补。 ch=getchar(); }}SUB *insert(SUB *head){ SUB *ptr,*ptr2,* int size=sizeof(SUB); char ch='a',ch1; while(ch!=' '){
subj=(SUB *)malloc(size);
printf("输入要插入的课程信息:\n");
scanf("%d%s%s%d%d%d%d%d",&subj-&num,subj-&name,subj-&kind,&subj-&stime,&subj-&ttime,&subj-&etime,&subj-&score,&subj-&term);
if(head==NULL){
head-&next=NULL;
for(ptr2=ptr2;ptr2=ptr2-&next)
if(ptr2-&next==NULL){
ptr2-&next=
subj-&next=NULL;
printf("继续插入请按回车,结束请按空格:\n");
ch1=getchar();
//将回车键赋给CH1,否则subj-&term输完后输入的回车键会赋给CH,因此用CH1填补。
ch=getchar();
}}SUB *del(SUB *head){ SUB *p1,*p2; char ch='a',ch1; while(ch!=' '){
printf("输入想要删除的课程编号:\n");
scanf("%d",&num);
if(head-&num==num){
head=head-&
if(head==NULL)
return NULL;
while(p2){
if(p2-&num==num){
p1-&next=p2-&
else p1=p2;
printf("继续删除请按回车,结束请按空格:\n");
ch1=getchar();
//将回车键赋给CH1,否则num输完后再输入的回车键会赋给CH,因此用CH1填补。
ch=getchar(); }} void choose(SUB *head){ SUB *p,*q; int a[5]; int num,total=0,i=0,j; printf("输入要选修的课程的编号,编号之间以空格分开,输完后以0结束\n"); scanf("%d",&num); while(num!=0){
for(p=p;p=p-&next)
if(p-&num==num){
total=total+p-&
scanf("%d",&num); } if(total&60) printf("选修总学分未达到60,选修失败!\n"); else {
printf("选修成功!\n");
printf("您选修的课程为:\n"); for(j=0;j&i;j++)
for(q=q;q=q-&next)
if(q-&num==a[j])
printf("%s
",q-&name); printf("\n");printf("***********************************\n");printf("
\n");printf("
\n");printf("***********************************\n");
}}void main(){ SUB *head=create_form(); savefile(head); prin(head); search(head); head=insert(head);
//注意此处的必要性,函数insert的的返回值重新赋给head! savefileadd(head); printf("修改后的信息为:\n"); prin(head); head=del(head);
//注意此处的必要性,函数del的的返回值重新赋给head! savefiledel(head); printf("修改后的课程信息为:\n"); prin(head); choose(head);}===================================分割线===============================================请问是哪里出错了,为什么运行之后只有一步??????????求大触来帮帮忙解答一下!!!!!!!!!!!!!!!!
这位童鞋很懒,什么也没有留下~~!
你问问题时候如果要插入代码的话,在编辑器上面有个代码语言,下拉选择C/C++,然后在展开的框里面写代码,这么乱让人怎么看你的问题注意出在初始化的create_form里面输入语句的问题,如果按照你原来的代码输入0以后还得输入课程名称,之前的代码是我学艺不精,直接学的C++,把很多C的写法当成错的,现全部删去
你还没有登录,请先登录或注册慕课网帐号
11691人关注
Copyright (C)
All Rights Reserved | 京ICP备 号-2

我要回帖

更多关于 宫斗求职表格 的文章

 

随机推荐