posts - 1,comments - 0,trackbacks - 0
/***********************************/ /* Turbo C2.0下运行通过 */ /* 一个和学生管理有关的程序 */ /* http://huaigong.myrice.com */ /***********************************/ #include<graphics.h> #include <process.h> #include<stdlib.h> #include<alloc.h> #include<ctype.h> #include<math.h> #include<stdio.h> #include<dos.h> #include<stdlib.h> #define TRUE 1 #define FALSE 0 #define KB_LEFT 75 #define KB_RIGHT 77 #define KB_ENTER 28 #define KB_Q 16 #define pi 3.1415926 #define COLOR1 WHITE #define COLOR2 YELLOW int MaxColor; int n=0; int get_key(); int choice(int x,int y); int get_item(int,int); int adin(int ch,int n); void *gb; void kitty() { int gdriver=VGA,gmode=VGAHI; int i,j,x[40],y[40]; initgraph(&gdriver,&gmode,"e:\\tc"); cleardevice(); setcolor(3); setfillstyle(LTBKSLASH_FILL,3); ellipse(350,270,0,360,240,160); floodfill(350,270,3); setcolor(14); moveto(420,310); lineto(300,450); lineto(540,450); lineto(420,310); setfillstyle(SOLID_FILL,14); floodfill(420,380,14); setcolor(RED); circle(420,250,120); setfillstyle(SOLID_FILL,WHITE); floodfill(420,250,RED); setcolor(BLACK); circle(350,240,10); circle(490,240,10); setfillstyle(SOLID_FILL,BLACK); floodfill(350,240,BLACK); floodfill(490,240,BLACK); setcolor(12); circle(340,270,14); circle(500,270,14); setfillstyle(BKSLASH_FILL,4); floodfill(340,260,12); floodfill(500,260,12); setcolor(BLACK); setfillstyle(SOLID_FILL,RED); fillellipse(410,130,50,80); fillellipse(510,150,50,80); setcolor(0); circle(505,150,35); circle(415,130,35); setfillstyle(SOLID_FILL,BLACK); floodfill(505,150,0); floodfill(415,130,0); setcolor(6); circle(460,140,30); setfillstyle(SOLID_FILL,0); floodfill(460,140,6); setcolor(4); arc(420,300,225,315,20); ellipse(420,321,170,365,6,10); setfillstyle(SOLID_FILL,4); floodfill(420,330,4); circle(200,60,40); circle(162,88,40); circle(238,88,40); circle(176,132,40); circle(224,132,40); circle(100,170,30); circle(129,191,30); circle(71,191,30); circle(82,224,30); circle(118,224,30); circle(100,200,6); setfillstyle(SOLID_FILL,14); floodfill(200,60,4); floodfill(162,88,4); floodfill(238,88,4); floodfill(176,132,4); floodfill(224,132,4); setfillstyle(SOLID_FILL,5); floodfill(100,170,4); floodfill(129,191,4); floodfill(71,191,4); floodfill(82,224,4); floodfill(118,224,4); setcolor(0); circle(200,100,10); setfillstyle(SOLID_FILL,15); floodfill(200,100,0); setcolor(7); ellipse(330,380,0,360,50,15); ellipse(510,380,0,360,50,15); setfillstyle(SOLID_FILL,12); floodfill(330,380,7); floodfill(510,380,7); setcolor(8); circle(270,380,20); circle(570,380,20); setfillstyle(SOLID_FILL,15); floodfill(270,380,8); floodfill(570,380,8); setcolor(3); circle(360,459,20); circle(480,459,20); setfillstyle(SOLID_FILL,15); floodfill(360,451,3); floodfill(480,451,3); settextjustify(0,2); settextstyle(4,0,3); setcolor(14); for(i=0;i<30;i++) y[i]=15*i+10; for(j=0;j<30;j++) {arc(10,y[j],0,180,5); arc(20,y[j],0,180,5); ellipse(15,y[j],180,360,10,15); arc(620,y[j],0,180,5); arc(610,y[j],0,180,5); ellipse(615,y[j],180,360,10,15);delay(2000); } for(i=0;i<=30;i++) x[i]=20*i+15; for(j=0;j<=30;j++) {arc(x[j]-5,10,0,180,5); arc(x[j]+5,10,0,180,5); ellipse(x[j],10,180,360,10,15); arc(x[j]-5,445,0,180,5); arc(x[j]+5,445,0,180,5); ellipse(x[j],445,180,360,10,15);delay(2000); } setcolor(12); settextstyle(0,0,3); outtextxy(200,20,"Hi,this a wondful place!"); delay(15000); setcolor(13); outtextxy(60,380,"You are welcome"); getch(); closegraph() ; } void goodbyer(void) { int gdriver=VGA,gmode=VGAHI; long t; struct palettetype pt; int x,c=COLOR1;int k;int i,j; unsigned size;void *buf,*bike; initgraph(&gdriver,&gmode,"e:\\tc"); cleardevice(); setbkcolor(9); setcolor(14); setfillstyle(SOLID_FILL,14); moveto(160,40); lineto(163,47); lineto(170,47); lineto(164,51); lineto(166,58);lineto(160,54); lineto(154,58); lineto(155,51); lineto(150,47); lineto(157,47); lineto(160,40); floodfill(160,43,14); size=imagesize(160,40,166,60);buf=malloc(size); if(buf) getimage(160,40,166,60,buf); cleardevice(); setcolor(12); setlinestyle(0,0,3); circle(530,390,60); moveto(530,330); lineto(540,315); ellipse(542,305,0,360,20,6); circle(327,350,100); moveto(327,350);lineto(530,390); arc(327,350,45,115,105); moveto(335,246);lineto(342,216); moveto(314,209); lineto(370,215); moveto(449,375); lineto(440,402); ellipse(440,409,0,360,15,5); for(i=0;i<=12;i++) { moveto(327,350); lineto(cos(i*pi/6)*100+327,350-sin(i*pi/6)*100); } for(i=0;i<=12;i++) {moveto(530,390); lineto(cos(i*pi/6)*60+530,390-sin(i*pi/6)*60); } bike=malloc(imagesize(200,180,630,460)); if(bike) getimage(200,180,630,460,bike); /* for(;!kbhit();) for(x=200;x>=20;x-=50) { putimage(x,180,bike,XOR_PUT); delay(500); putimage(x-50,180,bike,COPY_PUT); }*/ setcolor(7); setfillstyle(SOLID_FILL,7); arc(100,100,173,277,50); arc(80,120,140,310,40); floodfill(46,140,7); for(;!kbhit();) for(x=50;x<=600;x+=30) { putimage(x+9,40,buf,COPY_PUT); delay(1500); putimage(x+9,40,buf,XOR_PUT); } for(x=200;x>=20;x-=50) { putimage(x,180,bike,XOR_PUT); delay(1000); putimage(x-50,180,bike,COPY_PUT); } delay(10000); gettime(&t); srand(t); MaxColor=getmaxcolor(); getpalette(&pt); settextjustify(CENTER_TEXT,CENTER_TEXT); show_char(); for(i=0;i<640;i+=10) { setfillstyle(1,c=c==COLOR2?COLOR1:COLOR2); bar(i,100,i+10,110); } for(i=110;i<300;i+=10) {setfillstyle(1,c=c==COLOR2?COLOR1:COLOR2); bar(i,100,i+10,110); } for(i=630;i>=0;i-=10) {setfillstyle(1,COLOR2?COLOR1:COLOR2); bar(i,300,i+10,310 ) ; } for(i=290;i>100;i-=10) {setfillstyle(1,c=c==COLOR2?COLOR1:COLOR2); bar(0,i,10,i+10); } setfillstyle(SOLID_FILL,0); for(;!kbhit();) {show_char() ; for(k=0;k<8;k++) {setpalette(COLOR1,k&1?pt.colors[COLOR1]:pt.colors[COLOR2]); setpalette(COLOR2,k&1?pt.colors[COLOR2]:pt.colors[COLOR1]); if(k<8) for(i=1;i++<30000;) for(j=1;j++<2;) ; } } getch(); getch(); closegraph(); } show_char() {static int font=0; int c=random(MaxColor+1); static font_size[]={7,10,20,10,10,10}; if(c!=BLACK) setcolor(c); else setcolor(random(MaxColor+1)); bar(10,110,630,300); settextstyle(font,HORIZ_DIR,font_size[font]); setfillstyle(1,11); fillellipse(315,185,175,55); outtextxy(310,200,"Good");delay(10000); setfillstyle(1,14); fillellipse(315,185,175,55); setcolor(5); outtextxy(310,200,"Bye"); delay(10000); setfillstyle(1,10);fillellipse(315,185,175,55); setcolor(13);outtextxy(310,200,"See"); delay(10000); setfillstyle(1,12); fillellipse(315,185,175,55); setcolor(14); outtextxy(310,200,"You"); settextstyle(1,0,5); setcolor(5); outtextxy(100,260,"T");delay(1500); outtextxy(130,260,"h");delay(1500); outtextxy(160,260,"a");delay(1500); outtextxy(190,260,"n"); delay(1500); outtextxy(220,260,"k");delay(1500); outtextxy(250,260,"s");delay(1500); outtextxy(290,260,"V");delay(1500); outtextxy(320,260,"e");delay(1500); outtextxy(350,260,"r");delay(1500); outtextxy(380,260,"y");delay(1500); outtextxy(420,260,"M");delay(1500); outtextxy(450,260,"u");delay(1500); outtextxy(480,260,"c");delay(1500); outtextxy(510,260,"h");delay(1500); setcolor(14); arc(60,270,60,120,10);arc(530,270,60,120,10); delay(10000); arc(80,270,60,120,10);arc(550,270,60,120,10); delay(10000); arc(70,272,240,300,10); arc(540,272,240,300,10); font=(font+1)%5; } main() { int driver=VGA,mode=VGAHI,flag=0; int ad[640]; int row,item_num,i,ch,y,n,data,done,k; float da; unsigned size; kitty(); for(i=0;i<640;i++) ad[i]=580/2; while(!flag) { driver=VGA; mode=VGAHI; initgraph(&driver,&mode,"e:\\tc\\"); setcolor(YELLOW); setfillstyle(1,YELLOW); fillellipse(51,50,50,20); size=imagesize(1,10,101,70); if(size!=1) gb=malloc(size); setfillstyle(1,YELLOW); fillellipse(51,50,50,20); getimage(1,10,101,70,gb); setcolor(YELLOW); rectangle(0,0,639,479); rectangle(0,457,639,479); setfillstyle(1,LIGHTBLUE); bar(1,458,638,478); setcolor(BLUE); outtextxy(90,467," his is a wonderful place! welcome!! "); setcolor(RED); outtextxy(90,467,"T"); setcolor(LIGHTGREEN); line(1,5,639,5); line(1,1,1,50); line(639,1,639,30); setcolor(LIGHTRED); line(1,73,639,73); line(1,76,639,76); setfillstyle(1,BLACK); /*setcolor(BLUE); rectangle(2,2,634,40);*/ /* bar(2,2,637,39);*/ item_num=6; setcolor(LIGHTGREEN); for(k=0;k<item_num;k++) { ellipse(51+107*k,50,0,360,50,20); floodfill(2,42,LIGHTGREEN); } settextstyle(1,HORIZ_DIR,4); setcolor(LIGHTGREEN); outtextxy(200,1,"how do you do !"); settextstyle(0,HORIZ_DIR,1); setcolor(WHITE); outtextxy(40,50," rite"); outtextxy(150,50," ist"); outtextxy(245,50," ort"); outtextxy(358,50," ictr"); outtextxy(460,50," aker"); outtextxy(570,50," uit"); setcolor(LIGHTRED); outtextxy(22,50,"(W)"); outtextxy(132,50,"(L)"); outtextxy(228,50,"(S)"); outtextxy(340,50,"(P)"); outtextxy(442,50,"(M)"); outtextxy(552,50,"(Q)"); /* putimage(1,10,gb,XOR_PUT);*/ /* setcolor(WHITE);*/ row=0; done=FALSE; do { row=get_item(row,item_num); switch(row) { case 0: setfillstyle(1,BLACK); bar(2,77,638,455); shuru();break; case 1: setfillstyle(1,BLACK); bar(2,77,638,455); shuchu();break; case 2: setfillstyle(1,LIGHTGREEN); bar(2,77,638,455); sort();break; case 3: setfillstyle(1,BLACK); bar(2,77,638,455); pic();break; case 4: setfillstyle(1,LIGHTBLUE); bar(2,77,638,455); maker();break; case 5: done=TRUE; goodbyer(); delay(50000); closegraph(); exit(0); } if(flag) {flag=0;break;} }while(!done); } restorecrtmode(); } int get_item(int row,int item_num) { int key,done; done=FALSE; do { key=get_key(); switch(key) { case KB_ENTER: done=TRUE;break; case KB_RIGHT: putimage(1+row*107,10,gb,XOR_PUT); if(row==item_num-1) row=0; else row+=1; putimage(1+row*107,10,gb,XOR_PUT); break; case KB_LEFT: putimage(1+row*107,10,gb,XOR_PUT); if(row==0) row=item_num-1; else row-=1; putimage(1+row*107,10,gb,XOR_PUT); break; case KB_Q: if(row!=5) { putimage(1+row*107,10,gb,XOR_PUT); row=5; putimage(1+row*107,10,gb,XOR_PUT);} done=TRUE;break; default:break; } }while(!done); return row; } int get_key() { union REGS rg; rg.h.ah=0; int86(0x16,&rg,&rg); return rg.h.ah; } int show(int ch,int n) { int a; a=(int)(10*(ch/2+1)*sin(2*3.14*n*(ch/2+2)/630)); return a; } maker() {settextstyle(1,HORIZ_DIR,4); setcolor(LIGHTGREEN); line(320,75,1,250); line(1,250,320,455); line(320,455,639,250); line(639,250,320,75); /* ellipse(320,250,0,360,300,100);*/ setcolor(YELLOW); outtextxy(150,180,"Maker : CHEN JUNYU"); delay(30000); setcolor(5); outtextxy(220,240,"Class : 99.5"); delay(30000); setcolor(15); outtextxy(181,300,"Data : 2000-7-10"); arc(50,140,60,120,30); arc(100,140,60,120,30); arc(75,120,240,300,40); setcolor(LIGHTRED); settextstyle(0,0,2); outtextxy(20,330,"please "); outtextxy(20,365,"give me"); outtextxy(20,400,"high marks!"); delay(10000); setcolor(15); arc(590,80,240,300,30); arc(540,80,240,300,30); arc(565,180,60,120,30); setcolor(14); outtextxy(540,330,"please"); outtextxy(510,365,"do not"); outtextxy(450,400,"make me cry!"); } help() {settextstyle(1,HORIZ_DIR,8); outtextxy(150,240,"HELP");} struct student {char num[8]; char name[20]; int score; } stu[20],change; shuru() {int i,c; FILE * fp; settextstyle(2,HORIZ_DIR,5);setcolor(BLACK); for(i=n;;i++) {n=n+1; setfillstyle(1,YELLOW); bar(2,73,638,455); outtextxy(170,80,"Now you are inputing information."); gotoxy(15,10);printf("Input student %d message:",i+1); gotoxy(22,12);printf(" Num :"); gotoxy(32,12); setcolor(BLUE);scanf("%s",stu[i].num); setcolor(BLACK); gotoxy(22,14);printf(" Name:"); gotoxy(32,14);scanf("%s",stu[i].name); gotoxy(22,16);printf("Score:"); gotoxy(32,16);scanf("%d",&stu[i].score); outtextxy(110,275,"Enter 'S' to stop input and other key continue..."); c=getch(); if(c=='s'||c=='S') {setcolor(YELLOW); outtextxy(180,360,"The light-strip can move now."); outtextxy(190,380,"You can do other program!"); outtextxy(225,410," <list or Sort >"); settextstyle(1,HORIZ_DIR,4); outtextxy(240,310,"STOP!"); break;} } fp=fopen("c:\\s.txt","w"); for(i=0;i<n;i++) if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1) printf("file write error!\n"); fclose(fp); } shuchu() {int i; FILE *fp; setcolor(LIGHTRED); if((fp=fopen("c:\\s.txt","r"))==NULL) {settextstyle(1,HORIZ_DIR,2); outtextxy(110,70,"ERROR !");} settextstyle(1,HORIZ_DIR,2); outtextxy(210,75,"The Students` Data"); for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++) {gotoxy(22,9+2*i);printf("%s",stu[i].num); gotoxy(35,9+2*i);printf("%s",stu[i].name); gotoxy(57,9+2*i);printf("%d",stu[i].score); outtextxy(135,125+32*i,"|");outtextxy(250,125+32*i,"|"); outtextxy(420,125+32*i,"|");outtextxy(490,125+32*i,"|"); outtextxy(140,105,"-------------------------"); outtextxy(140,140+32*i,"-------------------------");} fclose(fp); } sort() {FILE *fp; int i,j; settextstyle(1,HORIZ_DIR,2);setcolor(LIGHTBLUE); fp=fopen("c:\\s.txt","r"); for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(stu[i].score<stu[j].score) {change=stu[i];stu[i]=stu[j];stu[j]=change;} outtextxy(210,75,"The sort permition"); fp=fopen("c:\\s_sort.txt","w"); for(i=0;i<n;i++) {fwrite(&stu[i],sizeof(struct student),1,fp); gotoxy(22,9+2*i);printf("%s",stu[i].num); gotoxy(35,9+2*i);printf("%s",stu[i].name); gotoxy(57,9+2*i);printf("%d",stu[i].score); outtextxy(135,125+32*i,"|");outtextxy(250,125+32*i,"|"); outtextxy(420,125+32*i,"|");outtextxy(490,125+32*i,"|"); outtextxy(140,105,"-------------------------"); outtextxy(140,140+32*i,"-------------------------");} fclose(fp); } pic() {int h,i,j;double z;double sum=0;double y=0;double x=0;double per; FILE *fp; fp=fopen("c:\\s.txt","r"); setcolor(YELLOW);settextstyle(1,HORIZ_DIR,2); outtextxy(10,90,"The picture of students`"); outtextxy(10,120,"score proportion :"); for(i=0;i<n;i++) {sum=sum+stu[i].score;} for(j=0;j<n;j++) {z=360*stu[j].score/sum; setcolor(j+1);setfillstyle(XHATCH_FILL,j+1); y=y+z; pieslice(310,230,x,y,100);x=y;} for(h=0;h<n;h++) {per=100*stu[h].score/sum; setcolor(h+1); setfillstyle(XHATCH_FILL,h+1); pieslice(40+73*h,390,45,135,50); /*setfillstyle(XHATCH_FILL,h+1); bar3d(30+73*h,360,40+73*h,380,15,1);*/ gotoxy(5+9*h,25);printf("%.1f%",per);} fclose(fp); } int x=-40,y; int radiu=40;
posted on 2007-05-01 03:15 悲惨的狼 阅读(108) 评论(0)  编辑 收藏 引用 所属分类: 基础
只有注册用户登录后才能发表评论。