| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3208 人关注过本帖
标题:小女求程序一道
只看楼主 加入收藏
流星雨
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:JAVA风暴
等 级:版主
威 望:43
帖 子:1854
专家分:1868
注 册:2004-5-30
结帖率:56.76%
收藏
 问题点数:0 回复次数:47 
小女求程序一道

求C语言学生成绩管理系统程序一道,用链表实现。可查询,修改,登陆!

请各位朋友提供原代码!小女在此谢过!

搜索更多相关主题的帖子: 链表 C语言 学生 代码 
2004-08-06 12:34
mikewolf
Rank: 1
等 级:新手上路
帖 子:175
专家分:0
注 册:2004-7-3
收藏
得分:0 
随便在网上的论坛搜索一下,你能够找到很多的!
2004-08-06 12:41
mikewolf
Rank: 1
等 级:新手上路
帖 子:175
专家分:0
注 册:2004-7-3
收藏
得分:0 
*/第一部分*/ #include "math.h" /*数学库函数*/ #include "graphics.h"/*图形功能函数*/ #include "conio.h" /*调用DOS控制台I/O 子函数*/ #include "bios.h" /*调用ROM-BIOS 子程序函数*/ #include "process.h" /*进程管理函数*/ #include "string.h" /*串操作函数*/ #include "stdio.h" /*输入输出函数*/ #include "stdlib.h" /*转换子程序函数*/ #include "alloc.h" /*内存管理函数*/ #define LEFT 331 #define RIGHT 333 #define UPPER 328 #define DOWN 336 #define ALT_X 301 #define ESC 27 #define ENTER 13 #define ALL 100 struct days { int year; int month; int date;} ; struct mark { int score1[5]; float ave1; int xf ; }; struct student { char name[10]; int num; char sex[6]; char class[10]; struct days birth; char pol[10]; char addr[10]; struct mark score; struct mark xf; }stu[ALL],MID;

void into(); void out(); void quit(); void insert(); void sort(); void delete(); void fromname(); void fromnum(); void pass(); void best(); void sars(); void fengm(); void load();

void WrtMnMenu(); void WrtSbMenu(); void SlctMenu(); void SlctMnMenu(); void SlctSbMenu(); int GetKey(); void SbFunGo(); void Screen(); void Wind(int ,int ,int, int ,int ,int ,int,int,int); void Quit(); int Mm=0; int Smm[4]; int SbNum[4]={3,3,2,2}; int SbWid[4]={10,10,10,10}; int SbX[4]={5,20,33,47}; int Key=0; char Buf[1000]; int x1=5,y1=3,x2=76,y2=23; char *Main[4]={"学生档案","档案修改","档案查找","成绩统计"}; char *Sub[4][6]={ {"输入档案", "输出档案", "退出"}, {"插入", "排序", "删除" }, {"由姓名", "由学号" }, {"及格人数", "优秀人数", "平均分" }}; main() {sars(); load(); fengm(); Screen(); WrtMnMenu(); WrtSbMenu(); SlctMenu(); Quit(); return(0);} void sars() { int gd=DETECT,gm,i,n; float t,x[6],y[6],a[5],b[5]; initgraph(&gd,&gm,"d:\\tc"); bar(45,49,50,440); setfillstyle(1,RED); bar(50,50,590,430); t=6.28/5;

/*大五角星*/ for(i=0;i<6;i++) { x[i]=140+45*cos(.1*3.14+i*t-3.14); y[i]=145+45*sin(.1*3.14+i*t-3.14); } for(i=0;i<5;i++) { a[i]=140+17*cos(.1*3.14+i*t+3.77); b[i]=145+17*sin(.1*3.14+i*t+3.77); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } setfillstyle(1,YELLOW); floodfill(140,145,YELLOW); /*小五角星1*/ for(i=0;i<6;i++) { x[i]=240+15*cos(.314+i*t-3.14-.8); y[i]=80+15*sin(.314+i*t-3.14-.8); } for(i=0;i<5;i++) { a[i]=240+6*cos(.314+i*t+3.77-.8); b[i]=80+6*sin(.314+i*t+3.77-.8); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } floodfill(240,80,YELLOW); /*小五角星2*/ for(i=0;i<6;i++) { x[i]=270+15*cos(.314+i*t-3.14-.5); y[i]=120+15*sin(.314+i*t-3.14-.5); } for(i=0;i<5;i++) { a[i]=270+6*cos(.314+i*t+3.77-.5); b[i]=120+6*sin(.314+i*t+3.77-.5); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } floodfill(270,120,YELLOW); /*小五角星3*/ for(i=0;i<6;i++) { x[i]=270+15*cos(.314+i*t-3.14+.05); y[i]=170+15*sin(.314+i*t-3.14+.05); } for(i=0;i<5;i++) { a[i]=270+6*cos(.314+i*t+3.77+.05); b[i]=170+6*sin(.314+i*t+3.77+.05); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } floodfill(270,170,YELLOW); /*小五角星4*/ for(i=0;i<6;i++) { x[i]=240+15*cos(.314+i*t-3.14+.2); y[i]=210+15*sin(.314+i*t-3.14+.2); } for(i=0;i<5;i++) { a[i]=240+6*cos(.314+i*t+3.77+.2); b[i]=210+6*sin(.314+i*t+3.77+.2); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } floodfill(240,210,YELLOW); settextstyle(0, 0, 3); outtextxy( 74,432,"我们中国人不怕SARS!"); getch(); };

void load() {int driver=DETECT,mode; initgraph(&driver,&mode,"");

setbkcolor(0); settextstyle(0,0,0); outtextxy(264,300,"Loading......"); setfillstyle(SOLID_FILL,GREEN); bar(184,320,449,328); sleep(1); setfillstyle(SOLID_FILL,LIGHTGREEN); bar(184,320,214,328); sleep(1); bar(214,320,261,328); sleep(1); bar(261,320,308,328); sleep(1); bar(308,320,355,328); sleep(1); bar(355,320,402,328); sleep(1); bar(402,320,449,328); sleep(1); closegraph(); } void fengm() {int gdrive=DETECT,gmode; initgraph(&gdrive,&gmode,""); setbkcolor(0);

setfillstyle(SOLID_FILL,LIGHTBLUE); bar(20,15,620,295);

setfillstyle(SOLID_FILL,BLACK); bar(100,70,580,250);

setfillstyle(SOLID_FILL,LIGHTGRAY); bar(80,55,560,235);

setfillstyle(SOLID_FILL,BLACK); bar(160,110,520,190);

setfillstyle(SOLID_FILL,RED); bar(140,95,500,175);

rectangle(23,18,617,292); rectangle(83,58,557,232); settextstyle(0,0,2); outtextxy(190,125,"学生信息管理系统"); /*一个汉字8*8点阵?*/ settextstyle(0,0,1); outtextxy(320,204,"摆渡人工作组制作"); outtextxy(410,264,"2003年5月"); line(0,450,640,450); settextstyle(0,0,1); outtextxy(260,456,"按任意键继续......"); getch(); closegraph(); }

void WrtMnMenu() /*写主菜单*/ { int i; window(1,1,80,25); textattr(0x3e); for(i=0;i<4;i++) { gotoxy(SbX[i],1); cputs(Main[i]); } gotoxy(SbX[Mm],1); textattr(0x4e); cputs(Main[Mm]); if(Key==ESC||Key==ALT_X) exit(0);} void WrtSbMenu() /*写下拉式菜单*/ { int i; gettext(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm]+1,SbNum[Mm]+4,Buf); Wind(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm],SbNum[Mm]+3,1,1,3,15,1); textattr(0x3f); for(i=0;i<SbNum[Mm];i++) { gotoxy(2,1+i); cputs(Sub[Mm][i]);} textattr(0x1e); gotoxy(2,Smm[Mm]+1); cputs(Sub[Mm][Smm[Mm]]); } void SlctMenu() /*选择菜单*/ { while (Key!=ALT_X&&Key!=ESC) { Key=GetKey(); if(Key==LEFT||Key==RIGHT) SlctMnMenu(); if(Key==UPPER||Key==DOWN) SlctSbMenu(); if(Key==ENTER) SbFunGo();} return;} void SlctMnMenu() /*选择主菜单*/ {window(1,1,80,25); textattr(0x3e); gotoxy(SbX[Mm],1); cputs(Main[Mm]); textattr(0x31); puttext(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm]+1,SbNum[Mm]+4,Buf); if(Key==LEFT) Mm=Mm==0?3:Mm-1; if(Key==RIGHT) Mm=Mm==3?0:Mm+1; textattr(0x4e); gotoxy(SbX[Mm],1); cputs(Main[Mm]); WrtSbMenu();} void SlctSbMenu() /*选择下拉式菜单*/ {textattr(0x3f); gotoxy(2,1+Smm[Mm]); cputs(Sub[Mm][Smm[Mm]]); if(Key==UPPER) Smm[Mm]=Smm[Mm]==0?SbNum[Mm]-1:Smm[Mm-1]; if(Key==DOWN) Smm[Mm]=Smm[Mm]==SbNum[Mm]-1?0:Smm[Mm]+1; textattr(0x1e); gotoxy(2,Smm[Mm]+1); cputs(Sub[Mm][Smm[Mm]]);}

int GetKey() {int Ch,Low,Hig; Ch=bioskey(0); Low=Ch&0x00ff; Hig=(Ch&0xff00)>>8; return(Low==0?Hig+256:Low);} void SbFunGo() /*执行菜单命令*/ { void *buffer; /*buffer=(void *)calloc(100);*/ switch(Mm) {case 0: switch(Smm[0]) /*输入档案*/ { case 0: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); into(); puttext(1,1,80,25,buffer); free(buffer); break; case 1: /*输出档案*/ buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); out(); puttext(1,1,80,25,buffer); free(buffer); break; case 2: /*退出*/ buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); quit(); puttext(1,1,80,25,buffer); free(buffer); break; } break; case 1: /*插入档案*/ switch(Smm[1]) { case 0: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); insert(); puttext(1,1,80,25,buffer); free(buffer); break; case 1: /*排序*/ buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); sort(); puttext(1,1,80,25,buffer); free(buffer); break; case 2: /*删除档案*/ delete(); buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); puttext(1,1,80,25,buffer); free(buffer); break; } break; case 2: /*按名字查询*/ switch(Smm[2]) { case 0: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); fromname(); puttext(1,1,80,25,buffer); free(buffer); break; case 1: /*按学号查询*/ buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); fromnum(); puttext(1,1,80,25,buffer); free(buffer); break; } break;

case 3: switch(Smm[3]) { case 0: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); pass(); puttext(1,1,80,25,buffer); free(buffer); break; case 1: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); best(); puttext(1,1,80,25,buffer); free(buffer);break; } break; } }

2004-08-06 12:45
mikewolf
Rank: 1
等 级:新手上路
帖 子:175
专家分:0
注 册:2004-7-3
收藏
得分:0 
*/第二部分*/
 void Screen()
 { window(1,1,80,25);
 textattr(0x17);
 clrscr();
 window(1,1,80,1);
 textattr(0x3e);
 clrscr();
 window(1,24,80,24);
 textattr(0x74);
 clrscr();
 cputs("\x18"); putchar(' ');
 cputs("\x19"); putchar(' ');
 cputs("\x1a"); putchar(' ');
 cputs("\x1b"); putchar(' ');
 textattr(0x7e);cputs(" ");
 textattr(0x74);cputs("  Enter");
 textattr(0x7e);cputs(" 选择菜单");
 textattr(0x74);cputs("  Alt_X");
 textattr(0x7e);cputs("或者");
 textattr(0x74);cputs(" ESC");
 textattr(0x7e);cputs(" 退出");
 window(1,25,80,25);
 textattr(0x3e);
 clrscr();
cputs(" 西 安 邮 电 学 院");
 Wind(1,2,80,23,2,0,1,15,1);
 window(1,1,80,25);
 }
 void Wind( int x1,int y1,int x2,int y2,int FR,int IS,int BC,int TC,int BG)
 { int i;
 int c[2][6]={{0xda,0xc4,0xbf,0xb3,0xc0,0xd9},
          {0xc9,0xcd,0xbb,0xba,0xc8,0xbc}};
 textcolor(TC);
 textbackground(BC);
 window(x1,y1,x2,y2);
 clrscr();
 if(FR)
 { window(1,1,80,25);
 gotoxy(x1,y1);
 putch(c[FR-1][0]);
 for(i=x1+1;i&lt;x2;i++)
 putch(c[FR-1][1]);
 putch(c[FR-1][2]);
 for(i=y1+1;i&lt;y2;i++)
 { gotoxy(x1,i);
 putch(c[FR-1][3]);
 gotoxy(x2,i);
 putch(c[FR-1][3]);}
 gotoxy(x1,y2);
 putch(c[FR-1][4]);
 for(i=x1+1;i&lt;x2;i++)
 putch(c[FR-1][1]);
 putch(c[FR-1][5]); }
 if(IS)
 textcolor(BG);
 textbackground(0);
 for(i=y1+1;i&lt;y2+1;i++)
 { gotoxy(x2+1,i); }
 for(i=x1+1;i&lt;x2+2;i++)
 { gotoxy(i,y2+1); }
 window(x1+1,y1+1,x2-1,y2-1);
 }
 void Quit()
 { textbackground(0);
 textcolor(7);
 window(1,1,80,25);
 clrscr();
 exit(0);}
void into()
  { char filename[15];
  int a,i,sum;  int j,x1,y1,x2,y2;
   FILE *fp;  void *buf;
   window(1,5,80,25);
 /*  buf=(void *)malloc(2*80*25);
   gettext(1,5,80,20,buf);   */
   Wind(1,2,80,23,2,0,1,15,1);
   textbackground(BLUE);
   cprintf("输入人数:");
    scanf("%d",&amp;a);
   for(i=0;i&lt;a&amp;&amp;Key!=ESC;i++)
   { Wind(1,2,80,23,2,0,1,15,1);
     textbackground(BLUE);
      cprintf("输入姓名:");
     scanf("%s",stu[i].name);gotoxy(2,2);
     cprintf("学生信息");gotoxy(2,3);
     cprintf("学号:");scanf("%d",&amp;stu[i].num);gotoxy(2,4);
     cprintf("班级:");scanf("%s",&amp;stu[i].class);gotoxy(2,5);
     cprintf("性别:");scanf("%s",stu[i].sex);gotoxy(2,6);
     cprintf("出生日期:");gotoxy(15,6);
     cprintf("年:");scanf("%d",&amp;stu[i].birth.year);gotoxy(23,6);
     cprintf("月:");scanf("%d",&amp;stu[i].birth.month);gotoxy(31,6);
     cprintf("日:");scanf("%d",&amp;stu[i].birth.date);gotoxy(2,7);
     cprintf("政治面貌:");scanf("%s",stu[i].pol);gotoxy(2,8);
     cprintf("家庭住址:");scanf("%s",stu[i].addr);
     getchar();clrscr();}
     for(i=0;i&lt;a&amp;&amp;Key!=ESC&amp;&amp;Key!=ALT_X;i++)
    { Wind(1,2,80,23,2,0,1,15,1);
   textbackground(BLUE);
    cprintf("姓名:%s",stu[i].name);gotoxy(2,2);
    cprintf("输入期末成绩:\n");
    printf("高等数学  英语  C语言  大学物理  马哲");gotoxy(2,4);
    scanf("%d%d%d%d%d",&amp;stu[i].score.score1[0],&amp;stu[i].score.score1[1],
    &amp;stu[i].score.score1[2],&amp;stu[i].score.score1[3],&amp;stu[i].score.score1[4]);
    printf("\nif you want to stop; please enter ESC");
      getchar();clrscr();}
   fp=fopen("a:\\stu.new","a+");
 for(i=0;i&lt;a;i++)
 fwrite(&amp;stu[i],sizeof(struct student),1,fp);
  fclose(fp);
   return; }
 void insert()                               /*插入学号*/
  { FILE *fp;
  int i,h,e,j,t, numb;
   Wind(1,2,80,23,2,0,1,15,1);
   textbackground(BLUE);
   cprintf("输入插入的学号:");
 scanf("%d",&amp;numb);
 if((fp=fopen("a:\\stu.new","r"))==NULL)
 {cprintf("文件打不开!");
 exit(0);}
 for(i=0,j=0;fread(&amp;stu[i],sizeof(struct student),1,fp)!=0;i++)
   if(stu[i].num&lt;numb)   j++;
 fclose(fp);
 h=j;
 fp=fopen("a:\\stu.new","r");
 for(i=0;fread(&amp;stu[i],sizeof(struct student),1,fp)!=0;i++) ;
 e=i;
  /*move datas*/
     for(j=e-1;j&gt;=h;j--)
    { stu[j+1]=stu[j]; }
    fclose(fp);
 fp=fopen("a:\\stu.new","w+");
   gotoxy(2,2);
   cprintf("输入姓名:");
   scanf("%s",stu[h].name);gotoxy(2,3);
   cprintf("学生信息:");gotoxy(2,4);
   cprintf("班级:");scanf("%s",&amp;stu[h].class);gotoxy(2,5);
   cprintf("性别:");scanf("%s",stu[h].sex);gotoxy(2,6);
   cprintf("出生日期:");gotoxy(15,6);
   cprintf("年:");scanf("%d",&amp;stu[h].birth.year);gotoxy(23,6);
   cprintf("月:");scanf("%d",&amp;stu[h].birth.month);gotoxy(31,6);
   cprintf("日:");scanf("%d",&amp;stu[h].birth.date);gotoxy(2,7);
   cprintf("政治面貌:");scanf("%s",stu[h].pol);gotoxy(2,8);
   cprintf("家庭住址:");scanf("%s",stu[h].addr);
   getchar();clrscr();
    cprintf("姓名:%s\n",stu[h].name);
     Wind(1,2,80,23,2,0,1,15,1);
   textbackground(BLUE);
    cprintf("输入期末成绩 :");gotoxy(2,2);
    printf("高等数学  英语  C语言  大学物理  马哲");gotoxy(2,3);
    scanf("%d%d%d%d%d",&amp;stu[h].score.score1[0],&amp;stu[h].score.score1[1],
    &amp;stu[h].score.score1[2],&amp;stu[h].score.score1[3],&amp;stu[h].score.score1[4]);
     for(i=0;i&lt;=e;i++)
      fwrite(&amp;stu[i],sizeof(struct student),1,fp);
     fclose(fp);  getchar();clrscr(); return;  }
void fromname()                              /*按名字查询*/
{  FILE *fp;
int i,n,flag=0,t;
char str[10],key;
  Wind(1,2,80,23,2,0,1,15,1);
   textbackground(BLUE);
 if((fp=fopen("a:\\stu.new","r"))==NULL)
 {printf("file can't open");  getch();
 exit(0);}
 for(i=0;fread(&amp;stu[i],sizeof(struct student),1,fp)!=0;i++);
 n=i;
 while(1)
 { Wind(1,2,80,23,2,0,1,15,1);
   textbackground(BLUE);
 cprintf("输入姓名:");
   scanf("%s",str);
   for(i=0;i&lt;n;i++)
  { if(strcmp(str,stu[i].name)==0)
    {gotoxy(2,2);cprintf("学生的信息:");gotoxy(2,3);
   cprintf("学号:%d",stu[i].num);gotoxy(2,4);
   cprintf("班级:%s",stu[i].class);gotoxy(2,5);
   cprintf("性别:%s",stu[i].sex);gotoxy(2,6);
   cprintf("出生日期:"); gotoxy(15,6);
   cprintf("年:%d",stu[i].birth.year);gotoxy(23,6);
   cprintf("月:%d",stu[i].birth.month);gotoxy(31,6);
   cprintf("日:%d",stu[i].birth.date);gotoxy(2,7);
   cprintf("政治面貌:%s",stu[i].pol);gotoxy(2,8);
   cprintf("家庭住址:%s",stu[i].addr);gotoxy(2,9);
   cprintf("期末成绩:");gotoxy(12,9);
   cprintf("高等数学:%d",stu[i].score.score1[0]);gotoxy(25,9);
   cprintf("英语:%d",stu[i].score.score1[1]);gotoxy(35,9);
   cprintf("C语言:%d",stu[i].score.score1[2]);gotoxy(45,9);
   cprintf("大学物理:",stu[i].score.score1[3]);gotoxy(58,9);
   cprintf("马哲:%d",stu[i].score.score1[4]);gotoxy(68,9);
   cprintf("平均分:%d",(stu[i].score.score1[0]+stu[i].score.score1[1]+
    stu[i].score.score1[2]+stu[i].score.score1[3]+stu[i].score.score1[4])/5);
       flag++; }
     }
    if(flag==0)
     { gotoxy(2,10);
       textattr(0x3e);
       cprintf(" 找不到!");
    }
       gotoxy(2,15);
       textattr(0x3e);
       cprintf("继续吗?(Y/N):");
      if((getch()=='n')||(getch()=='N'))
       { window(1,1,80,25);clrscr();break;}
    clrscr();     }
   fclose(fp);
    return;}
  void fromnum()                 /*按学号查询*/
   {  FILE *fp;
   int i,n,num,flag=0,t;
   char key;
   Wind(1,2,80,23,2,0,1,15,1);
   textbackground(BLUE);
 if((fp=fopen("a:\\stu.new","r"))==NULL)
 {printf("file can't open");  getch();
 exit(0);}
 for(i=0;fread(&amp;stu[i],sizeof(struct student),1,fp)!=0;i++);
 n=i;
2004-08-06 12:46
mikewolf
Rank: 1
等 级:新手上路
帖 子:175
专家分:0
注 册:2004-7-3
收藏
得分:0 
while(1) { Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); cprintf("输入学号:"); scanf("%d",&num); for(i=0;i<n;i++) { if(num==stu[i].num) {gotoxy(2,2);cprintf("姓名:%s",stu[i].name);gotoxy(2,3); cprintf("学号:%d",stu[i].num);gotoxy(2,4); cprintf("班级:%s",stu[i].class);gotoxy(2,5); cprintf("性别:%s",stu[i].sex);gotoxy(2,6); cprintf("出生日期");gotoxy(15,6); cprintf("年:%d",stu[i].birth.year);gotoxy(23,6); cprintf("月:%d",stu[i].birth.month);gotoxy(31,6); cprintf("日:%d",stu[i].birth.date);gotoxy(2,7); cprintf("政治面貌:%s",stu[i].pol);gotoxy(2,8); cprintf("家庭住址:%s",stu[i].addr);gotoxy(2,9); cprintf("期末成绩:");gotoxy(12,9); cprintf("高等数学:%d",stu[i].score.score1[0]);gotoxy(25,9); cprintf("英语:%d",stu[i].score.score1[1]);gotoxy(35,9); cprintf("C语言:%d",stu[i].score.score1[2]);gotoxy(45,9); cprintf("大学物理:%d",stu[i].score.score1[3]);gotoxy(58,9); cprintf("马哲:%d",stu[i].score.score1[4]);gotoxy(68,9); cprintf("平均分:%d",(stu[i].score.score1[0]+stu[i].score.score1[1]+ stu[i].score.score1[2]+stu[i].score.score1[3]+stu[i].score.score1[4])/5); flag++; } } if(flag==0) { gotoxy(2,7); textattr(0x3e); cprintf(" 找不到!"); } gotoxy(2,12); textattr(0x3e); cprintf("继续吗?(Y/N):"); if((getch()=='n')||(getch()=='N')) {window(1,1,80,25);clrscr(); break;} clrscr();} fclose(fp); return;}

void out() { FILE *fp; char key; int i,j,n; void *buffer; buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,1); cprintf("can't open!"); exit(0);}

for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0&&Key!=ESC;i++) { gotoxy(2,1); cprintf("假如想中断,按键B");gotoxy(2,2); cprintf("姓名:%s",stu[i].name);gotoxy(2,3); cprintf("学生信息:");gotoxy(2,4); cprintf("学号:%d",stu[i].num);gotoxy(2,5); cprintf("班级:%s",stu[i].class);gotoxy(2,6); cprintf("性别:%s",stu[i].sex);gotoxy(2,7); cprintf("出生日期");gotoxy(15,7); cprintf("年:%d",stu[i].birth.year);gotoxy(23,7); cprintf("月:%d",stu[i].birth.month);gotoxy(31,7); cprintf("日:%d",stu[i].birth.date);gotoxy(2,8); cprintf("政治面貌:%s",stu[i].pol);gotoxy(2,9); cprintf("家庭住址:%s",stu[i].addr);gotoxy(2,10); cprintf("输出期末成绩:");gotoxy(2,11); cprintf("高等数学:%d",stu[i].score.score1[0]);gotoxy(15,11); cprintf("英语:%d",stu[i].score.score1[1]);gotoxy(25,11); cprintf("C语言:%d",stu[i].score.score1[2]);gotoxy(35,11); cprintf("大学物理:%d",stu[i].score.score1[3]);gotoxy(48,11); cprintf("马哲:%d",stu[i].score.score1[4]);gotoxy(58,11); cprintf("平均分:%d",(stu[i].score.score1[0]+stu[i].score.score1[1]+ stu[i].score.score1[2]+stu[i].score.score1[3]+stu[i].score.score1[4])/5); cprintf("按任意键继续!"); key=getch(); if(key=='B'||key=='b') { clrscr(); puttext(1,1,80,25,buffer); free(buffer);getch(); return; } Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); } fclose(fp); return;} void sort() /* 排序 */ { FILE *fp; void *buffer; int i,j,n,sum1[ALL],p[ALL]; char key; buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); gotoxy(2,1); cprintf("由分数排名:"); gotoxy(30,1); cprintf("按任意键开始!"); getch(); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,5); cprintf("没有记录!"); getch(); exit(0);} for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++) {sum1[i]=stu[i].score.score1[0]+stu[i].score.score1[1]+stu[i].score.score1[2]+ stu[i].score.score1[3]+stu[i].score.score1[4]; stu[i].score.ave1=sum1[i]/5; p[i]=stu[i].score.ave1; n=i; fclose(fp); /*sort average*/ for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(p[i]<p[j]) /*平均分比较*/ { MID=stu[i]; stu[i]=stu[j]; stu[j]=MID;} fp=fopen("a:\\stu.new","a+"); for(i=0;i<n;i++) fwrite(&stu[i],sizeof(struct student),1,fp); fclose(fp); /*put out*/ gotoxy(2,2); cprintf("结果是:"); fp=fopen("a:\\stu.new","r"); for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0&&Key!=ESC;i++) { gotoxy(2,3); cprintf("想中断,按键 B"); gotoxy(2,4); cprintf("第%d名是:",i+1);gotoxy(2,5); cprintf("%s",stu[i].name);gotoxy(2,6); cprintf("期末成绩:");gotoxy(2,7); cprintf("高等数学:%d",stu[i].score.score1[0]);gotoxy(15,7); cprintf("英语:%d",stu[i].score.score1[1]);gotoxy(25,7); cprintf("C语言:%d",stu[i].score.score1[2]);gotoxy(35,7); cprintf("大学物理:%d",stu[i].score.score1[3]);gotoxy(48,7); cprintf("马哲:%d",stu[i].score.score1[4]);gotoxy(58,7); cprintf("平均分:%d",(stu[i].score.score1[0]+stu[i].score.score1[1]+ stu[i].score.score1[2]+stu[i].score.score1[3]+stu[i].score.score1[4])/5); printf("按任意键继续"); key=getch(); if(key=='B'||key=='b') { clrscr(); puttext(1,1,80,25,buffer); free(buffer);getch(); return;} Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); } fclose(fp); return;} } void quit() { char *log[]={"想退出?,YES OR NO?", "按键Y/N"}; char key; Wind(30,10,60,20,2,0,1,15,1); textbackground(BLUE); do{textcolor(WHITE); gotoxy(1,3);cprintf("%s",log[0]); textcolor(WHITE); gotoxy(4,5);cprintf("%s",log[1]); gotoxy(21,5); key=getch(); if(key=='y'||key=='Y') {window(1,1,80,25);clrscr();exit(0);} else if(key=='n'||key=='N') break;} while(1); window(1,1,80,25); } void delete() /*删除档案*/ { FILE *fp; void *buf; int i,j,logic,del,n; char ch,name[10]; window(1,1,80,25); buf=(void *)malloc(80*2*25); gettext(1,1,80,25,buf); Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,1); /*将文本从存储区考备到屏幕*/ cprintf("can't open!"); getch();puttext(1,1,80,25,buf);free(buf);return;} for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0&&Key!=ESC;i++); n=i; fclose(fp); gotoxy(2,1); cprintf("输入你想删除学生的姓名:"); scanf("%s",name); getch(); for(i=0,logic=1;i<n&&logic;i++) {if(strcmp(name,stu[i].name)==0) { del=i; logic=0;} } if(!logic) n--; else { gotoxy(2,4);cprintf("不能找到,按键返回!"); getch();puttext(1,1,80,25,buf);free(buf);return;}

fp=fopen("a:\\stu.new","w"); for(i=0;i<del;i++) fwrite(&stu[i],sizeof(struct student),1,fp); for(i=del+1;i<n;i++) fwrite(&stu[i],sizeof(struct student),1,fp); fclose(fp); gotoxy(2,5); cprintf("删除成功!"); getch(); puttext(1,1,80,25,buf);free(buf); return; } void pass() /*及格统计*/ { FILE *fp; int i,n,sum1[ALL],m1=0; char key; Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,1); cprintf("file can't open"); getch(); exit(0);} for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++); n=i; fclose(fp); for(i=0;i<n;i++) { if((stu[i].score.score1[0]>=60)&&(stu[i].score.score1[1]>=60) &&(stu[i].score.score1[2]>=60)&&(stu[i].score.score1[3]>=60) &&(stu[i].score.score1[4]>=60)) m1++; } gotoxy(2,6); cprintf("及格人数是(期末):%d",m1); getch(); clrscr(); return;} /*优秀统计*/ void best() { FILE *fp; int i,n,sum1[ALL]; int t1=0; char key; Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,1); cprintf("file can't open"); getch(); exit(0);} for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++); n=i; fclose(fp); for(i=0;i<n;i++) {sum1[i]=stu[i].score.score1[0]+stu[i].score.score1[1]+stu[i].score.score1[2]+ stu[i].score.score1[3]+stu[i].score.score1[4]; stu[i].score.ave1=sum1[i]/5; } for(i=0;i<n;i++) { if((stu[i].score.score1[0]>=60)&&(stu[i].score.score1[1]>=60) &&(stu[i].score.score1[2]>=60)&&(stu[i].score.score1[3]>=60) &&(stu[i].score.score1[4]>=60)&&(stu[i].score.ave1>=80)) t1++;} gotoxy(2,6); cprintf("优秀人数是(期末):%d",t1); getch(); clrscr(); return;}

2004-08-06 12:46
mikewolf
Rank: 1
等 级:新手上路
帖 子:175
专家分:0
注 册:2004-7-3
收藏
得分:0 
/*注意:以上是转贴的他人的算法*/
2004-08-06 12:47
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
mikewolf真殷勤,嘿嘿~~~

淘宝杜琨
2004-08-06 16:01
忆楠
Rank: 1
等 级:新手上路
帖 子:721
专家分:0
注 册:2004-7-5
收藏
得分:0 
我晕  我还以为是原创呢  看的我头晕眼花``

点 鼠 标 , 救 饥 民 http://www./
2004-08-06 16:43
Winter2002
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2004-8-5
收藏
得分:0 
“她”是男的吧?
2004-08-06 18:27
深蓝幻想
Rank: 1
等 级:新手上路
帖 子:104
专家分:0
注 册:2004-8-6
收藏
得分:0 

头都大啦

但怎么运行起来全是乱码呢?


!~!~!深蓝幻想,幻想深蓝!~!~! Qq:1235531
2004-08-06 18:43
快速回复:小女求程序一道
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024161 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved