📄 学生管理.c
字号:
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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -