为了账号安全,请及时绑定邮箱和手机立即绑定

请大神指教学生选课系统

请大神指教学生选课系统

C
九天安属 2017-01-05 20:44:22
#include <stdio.h>#include <stdlib.h>#include <windows.h>#include <string.h>#define N 20struct xk{ int num; char name[20]; char xz; int zks; int ks; int syks; int xf; int kk;}kc[N];void lr(){ FILE *fp; int i,n; fp=fopen("d://kcxx.txt","ab+"); if(fp==NULL){ printf("Can not open file\n"); exit(1); } printf("输入几门课程信息\n"); scanf("%d",&n); for(i=0;i<n;i++) { printf("请输入课程编号\n"); scanf("%d",&kc[i].num); printf("请输入课程名称\n"); gets(kc[i].name); printf("请输入课程性质\n"); scanf("%c",&kc[i].xz); printf("请输入课程总课时\n"); scanf("%d",&kc[i].zks); printf("请输入课程授课课时\n"); scanf("%d",&kc[i].ks); printf("请输入课程实验课时\n"); scanf("%d",&kc[i].syks); printf("请输入课程学分\n"); scanf("%d",&kc[i].xf); printf("请输入课程开课学期\n"); scanf("%d",&kc[i].kk); fwrite(&kc[i],sizeof(struct xk),8,fp); } fclose(fp);}void ll(){ FILE *fp; int i; fp=fopen("d://kcxx.txt","ab+"); if(fp==NULL){ printf("Can not open file\n"); exit(1); } for(i=0;i<N;i++){ fread(&kc[i],sizeof(struct xk),8,fp); printf("%d\t%s\t%c\t%d\t%d\t%d\t%d\t%d\t",&kc[i].num,&kc[i].name,&kc[i].xz,&kc[i].zks,&kc[i].ks,&kc[i].syks,&kc[i].xf,&kc[i].kk); } fclose(fp);}void xfcx(){ FILE *fp; struct xk kc1[N]; int i,n; fp=fopen("d://kcxx.txt","rb"); if(fp==NULL){ printf("Can not open file\n"); exit(1); } printf("输入学分\n"); scanf("%d",&i); for(n=0;n<N;n++){ fread(&kc1[n],sizeof(struct xk),1,fp); if(i==kc1[n].xf) { printf("%d\t%s\t%c\t%d\t%d\t%d\t%d\t%d\t",&kc[i].num,&kc[i].name,&kc[i].xz,&kc[i].zks,&kc[i].ks,&kc[i].syks,&kc[i].xf,&kc[i].kk); }}void xfcx(){ FILE *fp; struct xk kc1[N]; int i,n; fp=fopen("d://kcxx.txt","rb"); if(fp==NULL){ printf("Can not open file\n"); exit(1); } printf("输入学分\n"); scanf("%d",&i); for(n=0;n<N;n++){ fread(&kc1[n],sizeof(struct xk),1,fp); if(i==kc1[n].xf) { printf("%d\t%s\t%c\t%d\t%d\t%d\t%d\t%d\t",&kc[i].num,&kc[i].name,&kc[i].xz,&kc[i].zks,&kc[i].ks,&kc[i].syks,&kc[i].xf,&kc[i].kk); }}void cx(){ FILE *fp; int i; fp=fopen("d://kcxx.txt","ab+"); if(fp==NULL){ printf("Can not open file\n"); exit(1); } printf("1、学分查询,2、课程性质查询"); scanf("%d",&i); switch(i) { case 1:xfcx(); break; case 2:xzcx(); break; default:printf("输入有误,重新输入。\n"); sleep(1000); }}
查看完整描述

1 回答

?
qwerse

TA贡献5条经验 获得超0个赞

注视都没有,帮不了
查看完整回答
反对 回复 2017-01-10
  • 1 回答
  • 0 关注
  • 1436 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信