c语言的程序框图怎么写,C语言课程设计 |
您所在的位置:网站首页 › c语言的流程图框图知识点 › c语言的程序框图怎么写,C语言课程设计 |
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 printf("---You have success read data from file!!!---\n"); return h; /*返回头指针*/ } /*追加记录到文件*/ void append() { FILE *fp; /*定义指向文件的指针*/ STUDENT *info; /*新记录指针*/ int s1,i; char infile[10]; /*保存文件名*/ printf("\nplease new record\n"); info=(STUDENT *)malloc(sizeof(STUDENT)); /*申请空间*/ if(!info) { printf("\nout of memory"); /*没有申请到,内存溢出本函数结束*/ return ; } inputs("enter no:",info->no,11); /*调用inputs输入学号*/ inputs("enter name:",info->name,15); /*调用inputs输入姓名*/ printf("please input %d score \n",N); /*提示输入成绩*/ s1=0; for(i=0;i { do{ printf("score%d:",i+1); scanf("%d",&info->score[i]); /*输入成绩*/ if(info->score[i]>100||info->score[i]score[i]>100||info->score[i]score[i]; /*求总分*/ } info->sum=s1; /*保存总分*/ info->average=(float)s1/N; /*求均分*/ info->order=0; /*名次初始值为0*/ info->next=NULL; /*将新记录后继指针赋值为空*/ printf("Enter infile name,for example c:\\f1\\te.txt:\n"); scanf("%s",infile); /*输入文件名*/ if((fp=fopen(infile,"ab"))==NULL) /*向二进制文件尾增加数据方式打开文件*/ { printf("can not open file\n"); /*显示不能打开*/ exit(1); /*退出程序*/ } printf("\n -----Appending record!-----\n"); if(1!=fwrite(info,sizeof(STUDENT),1,fp)) /*写文件操作*/ { printf("-----file write error!-----\n"); return; /*返回*/ } printf("-----append sucess!!----\n"); fclose(fp); /*关闭文件*/ } /*文件拷贝*/ void copy() { char outfile[10],infile[10]; FILE *sfp,*tfp; /*源和目标文件指针*/ STUDENT *p=NULL; /*移动指针*/ clrscr(); /*清屏*/ printf("Enter infile name,for example c:\\f1\\te.txt:\n"); scanf("%s",infile); /*输入源文件名*/ if((sfp=fopen(infile,"rb"))==NULL) /*二进制读方式打开源文件*/ { printf("can not open input file\n"); exit(0); } printf("Enter outfile name,for example c:\\f1\\te.txt:\n"); /*提示输入目标文件名*/ scanf("%s",outfile); /*输入目标文件名*/ if((tfp=fopen(outfile,"wb"))==NULL) /*二进制写方式打开目标文件*/ { printf("can not open output file \n"); exit(0); } while(!feof(sfp)) /*读文件直到文件尾*/ { if(1!=fread(p,sizeof(STUDENT),1,sfp)) break; /*块读*/ fwrite(p,sizeof(STUDENT),1,tfp); /*块写*/ } fclose(sfp); /*关闭源文件*/ fclose(tfp); /*关闭目标文件*/ printf("you have success copy file!!!\n"); /*显示成功拷贝*/ } /*排序*/ STUDENT *sort(STUDENT *h) { int i=0; /*保存名次*/ STUDENT *p,*q,*t,*h1; /*定义临时指针*/ h1=h->next; /*将原表的头指针所指的下一个结点作头指针*/ h->next=NULL; /*第一个结点为新表的头结点*/ while(h1!=NULL) /*当原表不为空时,进行排序*/ { t=h1; /*取原表的头结点*/ h1=h1->next; /*原表头结点指针后移*/ p=h; /*设定移动指针p,从头指针开始*/ q=h; /*设定移动指针q做为p的前驱,初值为头指针*/ while(t->sumsum&&p!=NULL) /*作总分比较*/ { q=p; /*待排序点值小,则新表指针后移*/ p=p->next; } if(p==q) /*p==q,说明待排序点值大,应排在首位*/ { t->next=p; /*待排序点的后继为p*/ h=t; /*新头结点为待排序点*/ |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |