C语言大一下学期大程序

#include<stdio.h>
#include<graphics.h>
#include<dos.h>
#include<bios.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
# define S1  40
# define S2  40
# define S3  16
# define HZK1 "c:\\tc\\hzk40s"/*汉字库*/
# define HZK2 "c:\\tc\\hzk40s"
# define HZK3 "c:\\tc\\hzk16"
void yuanbing();/*圆饼图*/
void lujing();/*输入路径*/
void fxdd();/*繁星点点,进入动画*/
void duchengji();/*读文件成绩*/
void tiaoxingtu();/*条形图*/
void jisuan();/*计算用于圆饼图*/
void set_mouse(int x,int y);/*设置鼠标*/
void read_mouse(int *,int *,int *);/*读鼠标的位置和按键是否按下*/
void draw_mouse(int ,int);/*hua鼠标*/
int init(int ,int,int,int);/*鼠标初始化*/
void dksb();/*文件打开失败提醒*/
void wxzf();/*输入无效字符提醒*/
void voice();/*声音*/
void weiye();/*尾页动画*/
void huitu();/*绘制条形图*/
void disphz1(int ,int ,char *,int ,int );/*汉字处理*/
void disphz2(int ,int ,char *,int ,int );
void disphz3(int ,int ,char *,int ,int );

struct A
{
	char type;
	char date[3];
	long num;
	int headsize;
	int recsize;
	char empty[20];
}head;
struct B
{
	char name[10];
	char empty1;
	char tape;
	long begin;
	char width;
	char dig;
	char empty[14];
}file[6];
struct C
{
	char name[20];
	double english;
	double  math;
	double  phy;
	double com;
	double sort;
        double max;
}st[101];
char a[100]={0},hh[100]={0};
int m,fsd[5],f,bz,y,over,tx,yb,sss,cui,cc,dk,wx,ko,oo;
void wxzf()/*非法输入显示*/
{union{
		int key;
		char b[2];
		}u;    
char w[]="Illegal character!!",ww[]="Unable to recognize",www[]="Push TAB re-enter!!",aa[]="Push ESC quit";
    wx=0; 
 while(1)
   {    settextstyle(0,0,1);
        setcolor(14);
        outtextxy(325,45,w);
        outtextxy(325,55,ww);
        outtextxy(325,65,www);
        outtextxy(325,75,aa);
        u.key=bioskey(0);
        if(u.b[1]==15)
         {   settextstyle(0,0,1);setcolor(0);
             outtextxy(325,45,w);
             outtextxy(325,55,ww);
             outtextxy(325,65,www);
             outtextxy(325,75,aa);
             wx=2;break;
          }
         else if(u.b[1]==1)
            {settextstyle(0,0,1);setcolor(0);
             outtextxy(325,45,w);
             outtextxy(325,55,ww);
             outtextxy(325,65,www);
             outtextxy(325,75,aa);
             wx=1;break;
			}			
	}

}
void dksb()/*文件打开失败显示*/
{ 
	union{
			int key;
			char b[2];
		}u;
char w[]="File opening failed!!",ww[]="Push TAB re-enter",www[]="Push ESC quit";
    dk=0;
        while(1)
   {    settextstyle(0,0,1);
        setcolor(14);
        outtextxy(325,45,w);
        outtextxy(325,55,ww);
        outtextxy(325,65,www);
        u.key=bioskey(0);
        if(u.b[1]==15)
         {   settextstyle(0,0,1);setcolor(0);
             outtextxy(325,45,w);
             outtextxy(325,55,ww);
             outtextxy(325,65,www);
             dk=2;break;
         }
         else if(u.b[1]==1)
            {settextstyle(0,0,1);setcolor(0);
             outtextxy(325,45,w);
             outtextxy(325,55,ww);
             outtextxy(325,65,www);
             dk=1;break;
			}
    }
}
void lujing()/*输入路径*/
{FILE *fp;
 int gdriver=DETECT,gmode;
 union{
  int key;
  char b[2];
  }u;
 int w,i=0,k,o,p,j;
 char *p1="请输入文件路径:",*p2="重新输入",*p3="进入",*p4="文件打开失败",*p5="退出",*p6="文件默认结尾",*p7="文件默认盘",*p8="注释",*p9="一",*p10="二";
 char  d[2]={0},e[2]={0};int *p56;char www ,ww[]="Unable to recognize",ee[]="push f1 re-enter!";
 initgraph(&gdriver,&gmode,"");
 cleardevice();dk=0;wx=0;
 settextstyle(0,0,1);
 setcolor(8);
 setfillstyle(1,15);
 disphz3(50,30,p1,4,1);
 rectangle(50,45,305,73);
 floodfill(51,51,8);
 /*getimage(50,45,200,73,p56);*/
 setcolor(3);
 setfillstyle(1,4);
 bar3d(150,150,200,170,6,1);
 outtextxy(165,156,"Tab");
 disphz3(210,150,p2,4,1);
 setcolor(3);
 setfillstyle(1,4);
 bar3d(150,180,200,200,6,1);
 outtextxy(165,186,"ENT");
 disphz3(210,180,p3,4,1);
 setfillstyle(1,4);
 bar3d(150,210,200,230,6,1);
 outtextxy(165,216,"ESC");
 disphz3(210,210,p5,4,1);
 disphz3(50,80,p8,4,1);
 disphz3(80,100,p9,4,1);
 disphz3(100,100,p6,4,1);
 disphz3(80,120,p10,4,1);
 disphz3(100,120,p7,4,1);
 setcolor(4);
 outtextxy(80,85,":");
 outtextxy(200,105,".DBF");
 outtextxy(185,125,"C:");
  w=50;k=50;
  u.key=bioskey(1);
 while(u.b[1]!=1)
 {
  settextstyle(1,0,2);
  setcolor(0);
  if(w+15>305)
  ;
  else {setcolor(0);
  line(w,70,w+15,70);
  delay(20000);
  setcolor(15);
  line(w,70,w+15,70);
  delay(20000);}

  if(bioskey(1))
   { u.key=bioskey(1);
     if(u.b[0])
      {u.key=bioskey(0);
      if((u.b[0]==' ')||(u.b[0]==':')||(u.b[0]=='\\')||(u.b[0]>='0'&&u.b[0]<='9')||(u.b[0]=='.')||(u.b[0]=='_')||(u.b[0]>='a'&&u.b[0]<='z')||(u.b[0]>='A'&&u.b[0]<='Z'))
    { if(i<16)
       a[i]=u.b[0];
    d[0]=a[i];
    hh[i]=a[i];
    setcolor(0);settextstyle(0,0,2);
     outtextxy(50,48,a);
     w+=15;if(w>305)w=305;else
     i++;
    }}  
       if(u.b[0]&&i==16)
               bioskey(0);
       if(u.b[1]==15&&i==0)
          bioskey(0);      
       else if(u.b[1]==14&&i!=0)
	   { w-=15;
	   if(w<50)
		  w=50;
	   else
	   i--;
	   a[i]=0;hh[i]=0;
       cleardevice();settextstyle(0,0,1);setcolor(8);
       setfillstyle(1,15);
	disphz3(50,30,p1,4,1);
 	rectangle(50,45,305,73);/*对页面的绘制*/
 	floodfill(51,51,8);
 	/*getimage(50,45,200,73,p56);*/
 	setcolor(3);
 	setfillstyle(1,4);
 	bar3d(150,150,200,170,6,1);
 	outtextxy(165,156,"Tab");
 	disphz3(210,150,p2,4,1);
 	setcolor(3);
 	setfillstyle(1,4);
 	bar3d(150,180,200,200,6,1);
 	outtextxy(165,186,"ENT");
 	disphz3(210,180,p3,4,1);
 	setfillstyle(1,4);
 	bar3d(150,210,200,230,6,1);
 	outtextxy(165,216,"ESC");
 	disphz3(210,210,p5,4,1);
 	disphz3(50,80,p8,4,1);
 	disphz3(80,100,p9,4,1);
 	disphz3(100,100,p6,4,1);
 	disphz3(80,120,p10,4,1);
 	disphz3(100,120,p7,4,1);
 	setcolor(4);
 	outtextxy(80,85,":");
 	outtextxy(200,105,".DBF");
	outtextxy(185,125,"C:");
    setcolor(0);
    settextstyle(0,0,2);
	outtextxy(50,48,a);
	 }
	else if(u.b[1]==15)
	{i=0;w=50; 
	memset(a,0,sizeof(a));
	cleardevice();
	settextstyle(0,0,1);
	setcolor(8);
    setfillstyle(1,15);
    disphz3(50,30,p1,4,1);
 	rectangle(50,45,305,73);/*对页面的绘制*/
 	floodfill(51,51,8);
 	/*getimage(50,45,200,73,p56);*/
 	setcolor(3);
 	setfillstyle(1,4);
 	bar3d(150,150,200,170,6,1);
 	outtextxy(165,156,"Tab");
 	disphz3(210,150,p2,4,1);
 	setcolor(3);
 	setfillstyle(1,4);
 	bar3d(150,180,200,200,6,1);
 	outtextxy(165,186,"ENT");
 	disphz3(210,180,p3,4,1);
 	setfillstyle(1,4);
 	bar3d(150,210,200,230,6,1);
 	outtextxy(165,216,"ESC");
 	disphz3(210,210,p5,4,1);
 	disphz3(50,80,p8,4,1);
 	disphz3(80,100,p9,4,1);
 	disphz3(100,100,p6,4,1);
 	disphz3(80,120,p10,4,1);
 	disphz3(100,120,p7,4,1);
 	setcolor(4);
 	outtextxy(80,85,":");
 	outtextxy(200,105,".DBF");
	outtextxy(185,125,"C:");}
       else if(u.b[1]==28||u.b[1]==156)
	 {     p=strlen(a);
	     if((a[p-1]=='F'&&a[p-2]=='B'&&a[p-3]=='D'&&a[p-4]=='.')||(a[p-1]=='f'&&a[p-2]=='b'&&a[p-3]=='d'&&a[p-4]=='.'))
			 ;
		 else
		 {a[p]='.';a[p+1]='D';a[p+2]='B';a[p+3]='F';
		 }
               fp=fopen(a,"rb");
	   if(fp!=NULL)
	 {
	    y=1;fclose(fp);
	 }
           else {voice();/*文件打开失败声音提醒*/
		         dksb();
				 p=strlen(a);
                 a[p-1]=0;
                 a[p-2]=0;
                 a[p-3]=0;
                 a[p-4]=0;}

	}else  if(!u.b[0]) {voice();/*输入无效字符声音提醒*/
	wxzf();}
	 if(dk==2)/*重新输入处理*/
      {i=0;w=50;
	memset(a,0,sizeof(a));
	cleardevice();
	settextstyle(0,0,1);
	setcolor(8);
    setfillstyle(1,15);
    disphz3(50,30,p1,4,1);
 	rectangle(50,45,305,73);
 	floodfill(51,51,8);
 	/*getimage(50,45,200,73,p56);*/
 	setcolor(3);
 	setfillstyle(1,4);
 	bar3d(150,150,200,170,6,1);
 	outtextxy(165,156,"Tab");
 	disphz3(210,150,p2,4,1);
 	setcolor(3);
 	setfillstyle(1,4);
 	bar3d(150,180,200,200,6,1);
 	outtextxy(165,186,"ENT");
 	disphz3(210,180,p3,4,1);
 	setfillstyle(1,4);
 	bar3d(150,210,200,230,6,1);
 	outtextxy(165,216,"ESC");
 	disphz3(210,210,p5,4,1);
 	disphz3(50,80,p8,4,1);
 	disphz3(80,100,p9,4,1);
 	disphz3(100,100,p6,4,1);
 	disphz3(80,120,p10,4,1);
 	disphz3(100,120,p7,4,1);
	setcolor(4);
 	outtextxy(80,85,":");
 	outtextxy(200,105,".DBF");
	outtextxy(185,125,"C:");dk=0;}}
    if(y==1||dk==1||wx==1)
	   break;

  }
 closegraph();
}
void duchengji()/*读文件中的数据*/
{
	FILE *fp;
	long n,l=0,i,j,k,temp=0;
        double max;
	char p,Na[20]={0},math[20]={0},name[20]={0},english[20]={0},phy[20]={0},com[20]={0};
         fp=fopen(a,"rb");
	if(fp==NULL)
	{
		exit(1);
	}
	fread(&head,32,1,fp);
	l=(head.headsize-33)/32;
	for(i=1;i<=l;i++)
	{
		fread(&file[0].name,32,1,fp);
			if(strcmp(file[0].name,"姓名")==0)
				file[1]=file[0];
			if(strcmp(file[0].name,"数学")==0)
				file[2]=file[0];
			if(strcmp(file[0].name,"英语")==0)
				file[3]=file[0];
			if(strcmp(file[0].name,"物理")==0)
				file[4]=file[0];
			if(strcmp(file[0].name,"计算机")==0)
				file[5]=file[0];
	}
	fgetc(fp);
	for(i=0;i<head.num;i++)
	{
	fseek(fp,head.headsize+head.recsize*i,0);
	   p=fgetc(fp);
		if(p=='*')
		{

			continue;
		}
	    fseek(fp,head.headsize+head.recsize*i,0);
		fseek(fp,file[1].begin,1);
		fread(Na,file[1].width,1,fp);
		for(k=file[1].width-1;k>=0;k--)
		{
			if(Na[k]==32)
				Na[k]=0;
			else break;
		}
		  strcpy(st[m].name,Na);
		  fseek(fp,head.headsize+head.recsize*i,0);
	      fseek(fp,file[2].begin,1);
	      fread(math,file[2].width,1,fp);
	      st[m].math=atof(math);
              max=st[m].math;
		  fseek(fp,head.headsize+head.recsize*i,0);
	      fseek(fp,file[3].begin,1);
	      fread(english,file[3].width,1,fp);
	      st[m].english=atof(english);
                    if(st[m].english>max)
                         max=st[m].english;
		  fseek(fp,head.headsize+head.recsize*i,0);
	      fseek(fp,file[4].begin,1);
	      fread(phy,file[5].width,1,fp);
	      st[m].phy=atof(phy);

		  fseek(fp,head.headsize+head.recsize*i,0);
	      fseek(fp,file[5].begin,1);
	      fread(com,file[5].width,1,fp);
	      st[m].com=atof(com);
          if(st[m].com>max)
		     st[m].max=st[m].com;
		  else 
			  st[m].max=max;
		  st[m].sort=st[m].english+st[m].math+st[m].com;
		  m++;
		  for(j=0;j<20;j++)
		  {    Na[j]=0;
			  math[j]=0;
			  english[j]=0;
			   phy[i]=0;
			   com[i]=0;
		  }

	}
	  for(i=0;i<=m-2;i++)/*对成绩的排序*/
		{  k=i;
		for(j=i+1;j<=m-1;j++)
			if(st[j].sort>st[k].sort)
				k=j;
			st[101]=st[i];st[i]=st[k];st[k]=st[101];
		}
		for(i=0;i<m-1;i++)
		{
			if(st[i].sort==st[i+1].sort)
			{if(st[i].english<st[i+1].english)
			{st[101]=st[i];st[i]=st[i+1];st[i+1]=st[101];}
			}
		}
              fclose(fp);
}
void huitu(int f)/*绘制条形图,f为页数*/
{ int  device=VGA;
	 int mode=VGAHI;
   char *p3="",*p4="下一页",*p5="上一页",*p6="退出" ;
   char *p7="数学",*p8="英语",*p9="计算机",*p10="切换",*p11="各科成绩柱状图";char mm[3]={0};
   int jj[3]={14,8,5},w=0,k,i,j,z1;
   initgraph(&device,&mode,"");
   cleardevice();
   setfillstyle(1,3);
   rectangle(500,5,550,20);
   floodfill(501,10,15);
   disphz3(555,5,p7,3,1);
   setfillstyle(1,5);
   rectangle(500,22,550,35);
   floodfill(501,25,15);
   disphz3(555,22,p8,5,1);
   setfillstyle(1,6);
   bar3d(500,100,550,120,6,1);
   outtextxy(520,110,"(W)");
   disphz3(558,100,p10,6,1);
   setfillstyle(1,14);
   rectangle(500,37,550,52);
   floodfill(501,38,15);
   disphz3(558,37,p9,14,1);
   outtextxy(28,20,"y");
   outtextxy(510,310,"x");
   disphz1(100,10,p11,3,1);
   w=80;
   line(20,20,20,320);
   line(0,300,520,300);
   line(15,25,20,20);
   line(25,25,20,20);
   line(515,295,520,300);
   line(515,305,520,300);
   line(10,100,20,100);
   line(10,150,20,150);
   line(10,200,20,200);
   line(10,250,20,250);
   outtextxy(22,100,"100");
   outtextxy(22,150,"75");
   outtextxy(22,200,"50");
   outtextxy(22,250,"25");
   outtextxy(22,301,"0");
   if(m%3==0)
	   k=m/3-1;
   else k=m/3;
   for(i=0+f*3;i<3+f*3;i++)
   {    j=w+60;if(i>=m)
   break;sprintf(mm,"%d",i+1);
   outtextxy(w+5,300-st[i].max*2-22,mm);
   memset(mm,0,sizeof(mm));
   disphz3(w+30,300-st[i].max*2-30,st[i].name,jj[i%3],1);
   setfillstyle(1,3);
   bar3d(w,300-st[i].math*2,w+25,300,5,1);
   setfillstyle(1,5);
   bar3d(w+28,300-st[i].english*2,w+53,300,5,1);
  /*setfillstyle(1,11);
   bar3d(w+32,300-st[i].phy*2,w+62,300,5,1);*/
   setfillstyle(1,14);
   bar3d(w+55,300-st[i].com*2,w+80,300,5,1);
   w+=120;
	}w=80;
  for(i=0+f*3;i<3+f*3;i++)
   {j=w+60;
    if(f==0&&i==0)/*对按键变灰的处理*/
   z1=8;
  else if(f==k&&i==(k+1)*3-1)/*对按键变灰的处理*/
   z1=8;
  else z1=2;
   setfillstyle(1,z1);
   bar3d(w,310,j,360,6,1);
   setcolor(15);
  if(i%3==0)
   outtextxy((w+j)/2-5,342,"(A)");
 else if(i%3==1)
   outtextxy((w+j)/2-5,342,"(S)");
else if(i%3==2)
   outtextxy((w+j)/2-5,342,"(D)");
   w+=120;
}  disphz3(85,315,p5,15,1);
   disphz3(211,315,p6,15,1);
   disphz3(325,315,p4,15,1);

}
void tiaoxingtu()/*对文件数据的三科成绩总分排名,和各科成绩柱状图*/
{  union{
  int key;
  char b[2];
  }u;
   int  device=VGA;
	 int mode=VGAHI;
   unsigned int size;
   int sss=0,j,i,w=0,k,ff=0,key,z1,ll1=0,ll2=0,l=0,x,y,x0,y0,button=0,button0=0;
   char b;int *p;
   char *p3="崔文贺",*p4="下一页",*p5="上一页",*p6="退出" ;
   initgraph(&device,&mode,"");
   cleardevice();if(m%3==0)
	   k=m/3-1;
   else k=m/3;set_mouse(501,200);read_mouse(&x,&y,&button);
   size=imagesize(x,y,x+10,y+15);p=malloc(size);
   getimage(x,y,x+10,y+15,p);putimage(x,y,p,COPY_PUT);draw_mouse(x,y);closegraph();
       huitu(f); sss=0;
   while(1)/*键盘 鼠标操作*/
   {

       if(bioskey(1))
	{u.key=bioskey(1);
          if(u.b[0])
        {key=bioskey(0);
	       b=key;
	if(f==0&&(b=='a'||b=='A'))
	{l=1;}
	else if(f==k&&(b=='d'||b=='D'))
	{l=1;}
	else if((b=='d'||b=='D')&&f<k)/*向后翻页*/
	  {f++;oo=1;closegraph();
       huitu(f);   }
	else if((b=='a'||b=='A')&&f>0)/*向前翻页*/
	     {f--;oo=1;closegraph();
       huitu(f);   }
	if(b=='s'||b=='S')
	   {sss=1;}/*按s退出*/
	if(b=='W'||b=='w')
	{yb=1;oo=1;}/*按W进行条形图和柱状图的切换*/
          }
        }

    setfillstyle(1,15);
    x0=x;y0=y;
    button0=button;
	read_mouse(&x,&y,&button);
       if(x!=x0||y!=y0||button!=button0)
    	{if(oo==0)
	   {putimage(x0,y0,p,COPY_PUT);}
         else 
			 oo=0;
       getimage(x,y,x+10,y+15,p);
	if(x<600)
		draw_mouse(x,y);
	else  ;
    if(button==button0) 
		 ff=1;
	else ff=0;
	if(x>=80&&x<=140&&y>=310&&y<=360&&button&1==1&&f>0)
	  {if(f==1)
	    oo=1;
	    f--;
		closegraph();
        huitu(f);   }
      else if(x>=320&&x<=380&&y>=310&&y<=360&&button&1==1&&f<k)
	 {if(f==k-1)oo=1;f++;closegraph();
          huitu(f);}
      else if(x>=200&&x<=260&&y>=310&&y<=360&&button&1==1)
	 { sss=1;}/*按s退出*/
      else if(x>=80&&x<=140&&y>=310&&y<=360&&button&1==1&&f==0)
	    { l=1;}
      else if(x>=320&&x<=380&&y>=310&&y<=360&&button&1==1&&f==k)
	    {l=1;}
      else if(x>=500&&x<=560&&y>=100&&y<=120&&button&1==1)
		 {yb=1;oo=1;}
      else if(x>=80&&x<=140&&y>=310&&y<=360&&f!=0)/*对按键变红,然后恢复的处理*/
                {setcolor(RED);
                  outtextxy(105,342,"(A)");disphz3(85,315,p5,4,1);}
	  else if(x>=320&&x<=380&&y>=310&&y<=360&&f!=k)
               {setcolor(RED);
		  outtextxy(345,342,"(D)");disphz3(325,315,p4,4,1);
		  }
      else   if(x>=200&&x<=260&&y>=310&&y<=360)
                 {setcolor(RED);
                  outtextxy(225,342,"(S)");disphz3(211,315,p6,4,1);}
      else  if(x>=500&&x<=550&&y>=100&&y<=120)
                 {setcolor(RED);
                  outtextxy(520,110,"(W)");}
      else {setcolor(15);
            outtextxy(105,342,"(A)");
            outtextxy(345,342,"(D)");
            outtextxy(225,342,"(S)");
            outtextxy(520,110,"(W)");
            disphz3(85,315,p5,15,1);
            disphz3(211,315,p6,15,1);
            disphz3(325,315,p4,15,1);}}

      if(sss==1||yb==1)/*退出条形图,进入下一步*/
         break;

	}
   closegraph();
}
 void  jisuan()/*对三科平均分分布的计算,用于圆饼图的使用*/
 {   int i;
     for(i=0;i<m;i++)
	 {
		switch((int)(st[i].sort)/30)
	 {	case 10:  ;
		case 9:  fsd[0]++;break;
		case 8:  fsd[1]++;break;
		case 7:  fsd[2]++;break;
		case 6:  fsd[3]++;break;
		default : fsd[4]++;break;
	 }

	 }
 }
void yuanbing()/*三科平均分的圆饼图分布*/
{   union{
			int key;
			char b[2];
		}u;
     long sum=0,snm=0,i,kk=0,o=0;unsigned int size;
     double b[5]={0},e[5]={0},x1,y1,f,k=0;int *p;
     long c[5]={0},g[20]={0},x2,y2,j;
     char *p1="切换",*p2="下一步",*p3="平均成绩圆饼图",*p4="退出";
     char q;
     int d[5]={1,3,5,14,2},w,x,y,x0,y0,button=0,button0=0,oo=0;
     int  device=VGA;
	 int mode=VGAHI;
     initgraph(&device,&mode,"");
     cleardevice();
	 set_mouse(501,200);
	 read_mouse(&x,&y,&button);
	 size=imagesize(x,y,x+10,y+15);
	 p=malloc(size);
     size=imagesize(x,y,x+10,y+15);
	 p=malloc(size);
     getimage(x,y,x+10,y+15,p);
	 putimage(x,y,p,COPY_PUT);
	 draw_mouse(x,y);
     for(i=0;i<5;i++)
     {     sum+=fsd[i];
     }
     for(i=0;i<4;i++)/*对分数段所占的角度的计算*/
     { if(fsd[i])
       {b[i]=360/(double)sum*(double)fsd[i]*1.0;
       if((long)(b[i]+0.5)==(long)b[i])
	       c[i]=(long)b[i];
	  else c[i]=(long)b[i];
	  snm+=c[i];
		}
	 }
      c[i]=360-snm;w=0;
	 for(i=0;i<5;i++)/*绘制圆饼图*/
   {  if(fsd[i])
     {setcolor(d[i]);
      setfillstyle(1,d[i]);  
      pieslice(180,210,w,w+c[i],100);
      e[i]=(w+w+c[i])*1.0/2;
      w+=c[i];
	 }
   }
	 snm=0;
	 setcolor(15);
    for(i=0;i<5;i++)/*对百分比的显示的处理*/
  {
      if(fsd[i]&&sum)
      f=((double)fsd[i]/(double)sum*100);
      else f=0;
      if((long)(f+0.5)==(long)f)
      f=(long)f;
      else f=(long)f+1;      
      if(i==4)
      f=100-k;
      k+=f;
       if(e[i]&&fsd[i])
      {x1=cos(3.1415926/180*e[i])*100;
      y1=sin(3.1415926/180*e[i])*100;
      x2=x1*1.3+180;
      y2=210-y1*1.2;
      sprintf(g,"%.0f",f);
      outtextxy(x2,y2,g);
      outtextxy(x2+20,y2,"%");
      for(j=0;j<5;j++)
       g[j]=0;
      }
   }
   setfillstyle(1,1);/*注例*/
   rectangle(500,5,550,20);
   floodfill(501,10,15);
   outtextxy(440,5,"90-");
   setfillstyle(1,3);
   rectangle(500,22,550,35);
   floodfill(501,25,15);
   outtextxy(440,22,"80-89");
   setfillstyle(1,5);
   rectangle(500,37,550,52);
   floodfill(501,38,15);
   outtextxy(440,37,"70-79");
   setfillstyle(1,14);
   rectangle(500,54,550,69);
   floodfill(501,55,15);
   outtextxy(440,54,"60-69");
   setfillstyle(1,2);
   rectangle(500,71,550,86);
   floodfill(501,72,15);
   outtextxy(440,71,"0-59");
   setfillstyle(1,6);
   bar3d(500,100,550,120,6,1);
   outtextxy(520,110,"(W)");
   disphz3(558,100,p1,6,1);
   setfillstyle(1,9);
   bar3d(500,130,550,150,6,1);
   outtextxy(520,137,"(N)");
   disphz3(558,127,p2,9,1);
   setfillstyle(1,3);
   bar3d(500,160,550,180,6,1);
   outtextxy(510,167,"(ESC)");
   disphz3(558,159,p4,14,1);
   disphz1(10,10,p3,3,1);
   u.key=bioskey(1);
   while(u.b[1]!=1)/*按ESC退出*/ /*键盘和鼠标操作*/
   {u.key=bioskey(1);
     if(bioskey(1))
    {q=bioskey(0);
     if(q=='N'||q=='n')/*按N进入尾页*/
      {weiye();over=1;}
     if(q=='w'||q=='W')/*按W进行切换*/
       {tx=1;oo=1;}}
     setfillstyle(1,15);
     x0=x;y0=y;
     button0=button;
	 read_mouse(&x,&y,&button);
       if(x!=x0||y!=y0||button!=button0)
	{if(oo==0)
	putimage(x0,y0,p,COPY_PUT);
	 else oo=0;
     getimage(x,y,x+10,y+15,p);
	 if(x<600)draw_mouse(x,y)
		;
	 else  ;
     if(x>=500&&x<=550&&y>=130&&y<=150&&button&1==1)
        {weiye();over=1;}
     else if(x>=500&&x<=550&&y>=100&&y<=120&&button&1==1)
              {tx=1;oo=1;}
     else if(x>=500&&x<=550&&y>=160&&y<=180&&button&1==1)
                    {break;}
     else if(x>=500&&x<=550&&y>=100&&y<=120)/*对按键变红,然后恢复的处理*/
                {setcolor(RED); outtextxy(520,110,"(W)");}
     else if(x>=500&&x<=550&&y>=130&&y<=150)
                {setcolor(RED);  outtextxy(520,137,"(N)");} 
     else if(x>=500&&x<=550&&y>=160&&y<=180)
                {setcolor(RED);  outtextxy(510,167,"(ESC)");} 
     else {setcolor(15); outtextxy(520,137,"(N)"); outtextxy(520,110,"(W)");outtextxy(510,167,"(ESC)");}        
         } 
     if(over==1||tx==1)/*退出圆饼图进入下一步*/
        break;
   }
        closegraph();  
}
int init(int xmin,int xmax,int ymin,int ymax)/*鼠标初始化*/
{
   union REGS regs;
    regs.x.ax=0;
    int86(51,&regs,&regs);
    if(regs.x.ax==0)
       return 0;
    regs.x.ax=7;
    regs.x.cx=xmin;
    regs.x.dx=xmax;
    int86(51,&regs,&regs);
	regs.x.ax=8;
	regs.x.cx=ymin;
	regs.x.dx=ymax;
	int86(51,&regs,&regs);
	return -1;
}
void draw_mouse(int x,int y)/*画鼠标*/
{

	int d[16]={0,0,0,10,3,8,7,15,10,13,6,6,9,5,0,0};
    int i,a[16]={0};
    for(i=0;i<16;i++)
  {  if(i%2==0)
       a[i]=x+d[i];
      else a[i]=y+d[i];
  }

      setcolor(15);
      setfillstyle(1,0);
      fillpoly(8,a);
}
void read_mouse(int *px,int *py,int *pbutton)/*读取鼠标的位置和按键状态*/
{
	union REGS regs;
 	int x0=*px, y0=*py, button=*pbutton;
 	int x, y;
	regs.x.ax=3;
    int86(0x33,&regs,&regs);
	x=regs.x.cx;
	y=regs.x.dx;
	*pbutton=regs.x.bx;
	*px=x;
	*py=y;
}
void set_mouse(int x,int y)/*设置鼠标初始位置*/
{   _AX=4;
    _CX=x;
    _DX=y;
    geninterrupt(0x33);
}
void fxdd()/*繁星点点,用于程序打开时动画*/
{
   int x,y,i,j=40,t=40;
   int gmode,gdriver=DETECT;
   initgraph(&gdriver,&gmode,"");
   randomize();
    while(j--)
	{ x=random(640);
      y=random(480);
      putpixel(x,y,x%16);
   }
       while(t--)
     { x=random(640);
      y=random(480);
      putpixel(x,y,x%16);
      delay(4000);
      for(i=0;i<6000;i++)
      {x=random(640);
      y=random(480);
      putpixel(x,y,BLACK);}
	 }
      closegraph();
}
void disphz1(int x,int y,char *p,int color,int m)/*40*40像素的字体*/
{
	 int i,j,n,k,a;
	 FILE *fp;
	 char qh,wh;
	 long offset;
	 char buffer[S1*S1/8];
	 if((fp=fopen(HZK1,"rb"))==NULL)
		  exit(0);
	 while(*p!='\0')
	 {
		 qh=*p-0xa0;
		 p++;
		 wh=*p-0xa0;
		 p++;
		 offset=(94L*(qh-16)+wh-1)*S1*S1/8;
		 fseek(fp,offset,0);
		 fread(buffer,S1*S1/8,1,fp);
		 for(i=0;i<S1;i++)
		 {for(j=0;j<S1;j++)
		 {a=j%8;
		  if((buffer[S1/8*i+j/8]&(0x80>>a))!=0)
			  for(n=0;n<m;n++)
				  for(k=0;k<m;k++)
					  putpixel(x+j*m+n,y+i*m+k,color);
		 }
		 }x+=S1*m+10;
	 }fclose(fp);
}
void disphz2(int x,int y,char *p,int color,int m)/*40*40像素的字体,与上面间隔不同*/
{
	 int i,j,n,k,a;
	 FILE *fp;
	 char qh,wh;
	 long offset;
	 char buffer[S2*S2/8];
	 if((fp=fopen(HZK2,"rb"))==NULL)
		  exit(0);
	 while(*p!='\0')
	 {
		 qh=*p-0xa0;
		 p++;
		 wh=*p-0xa0;
		 p++;
		 offset=(94L*(qh-16)+wh-1)*S2*S2/8;
		 fseek(fp,offset,0);
		 fread(buffer,S2*S2/8,1,fp);
		 for(i=0;i<S2;i++)
		 {for(j=0;j<S2;j++)
		 {a=j%8;
		  if((buffer[S2/8*i+j/8]&(0x80>>a))!=0)
			  for(n=0;n<m;n++)
				  for(k=0;k<m;k++)
					  putpixel(x+j*m+n,y+i*m+k,color);
		 }
		 }x+=S2*m;
	 }fclose(fp);
}
void disphz3(int x,int y,char *p,int color,int m)/*16*16像素的字体*/
{
	 int i,j,n,k,a;
	 FILE *fp;
	 char qh,wh;
	 long offset;
	 char buffer[S3*S3/8];
	 if((fp=fopen(HZK3,"rb"))==NULL)
		  exit(0);
	 while(*p!='\0')
	 {
		 qh=*p-0xa0;
		 p++;
		 wh=*p-0xa0;
		 p++;
		 offset=(94L*(qh-1)+wh-1)*S3*S3/8;
		 fseek(fp,offset,0);
		 fread(buffer,S3*S3/8,1,fp);
		 for(i=0;i<S3;i++)
		 {for(j=0;j<S3;j++)
		 {a=j%8;
		  if((buffer[S3/8*i+j/8]&(0x80>>a))!=0)
			  for(n=0;n<m;n++)
				  for(k=0;k<m;k++)
					  putpixel(x+j*m+n,y+i*m+k,color);
		 }
		 }x+=S3*m;
	 }fclose(fp);
}
void sjm()/*首界面*/
{ union{
		int key;
		char b[2];
		}u;
	 int device=VGA;
	 int mode=VGAHI;
	 char *p1="程序设计";
     char *p2="进入系统";
	 char *p3="退出系统";
	 char *p4="欢迎";
     char *p5="条形图";
	 char *p6="直方图";
	 char *p7="程序功能介绍:";
     char *p8="开发者:";
	 char k;
     int *p;
     unsigned int size;
	 int a[]={70,20,55,40,30,40,55,60,40,90,70,70,100,90,85,60,110,40,85,40,70,20},x,y,x0,y0,button=0,button0=0;
	 fxdd();
	 initgraph(&device,&mode,"");
	 cleardevice();
	 set_mouse(501,200);
	 read_mouse(&x,&y,&button);
	 size=imagesize(x,y,x+10,y+15);
     p=malloc(size);
     getimage(x,y,x+10,y+15,p);
	 putimage(x,y,p,COPY_PUT);
	 draw_mouse(x,y);
	 setcolor(8);
	 disphz1(150,100,p1,15,2);
	 setfillstyle(1,3);
     disphz3(20,300,p7,4,1);
	 disphz3(125,330,p6,4,1);
	 disphz3(125,360,p5,4,1);
     disphz3(450,450,p8,4,1);
	/* rectangle(150,180,500,400);*/
	 bar3d(230,350,390,390,6,1);
	 setfillstyle(1,5);
	 bar3d(230,300,390,340,6,1);
	 disphz2(230,300,p2,3,1);
	 disphz2(230,350,p3,4,1);
	 setcolor(9);setfillstyle(1,15);
	 bar3d(400,350,440,390,6,1);
	 settextstyle(0,0,2);
	 outtextxy(400,365,"(S)");
	 setcolor(9);
	 setfillstyle(1,15);
	 bar3d(400,300,440,340,6,1);
	 outtextxy(400,315,"(W)");
	 setcolor(4);
	 rectangle(10,10,150,100);
	 setfillstyle(1,4);
	 floodfill(11,11,4);
	 setcolor(15);
	 line(10,100,10,240);
	 setfillstyle(1,14);
	 fillpoly(11,a);
	 setcolor(GREEN);
	 setfillstyle(1,14);
	 pieslice(320,290,30,150,100);
	 disphz2(275,220,p4,4,1);
     setcolor(15);
     settextstyle(1,0,10);
     outtextxy(60,80,"C");
     settextstyle(0,0,0);   
	 while(1)/*键盘鼠标操作*/
	  {   settextstyle(0,0,2);
         if(bioskey(1))
         {u.key=bioskey(1);
	     if(u.b[0])
             {k=bioskey(0);
          if(k=='W'||k=='w')/*按W进入程序*/
	     {closegraph(); break;}
	      else if(k=='S'||k=='s')/*按S退出程序*/
	      {closegraph();ko=1;break;}}}
               x0=x;y0=y;
         button0=button;
	     read_mouse(&x,&y,&button);
       	if(x!=x0||y!=y0||button!=button0)
		{putimage(x0,y0,p,COPY_PUT);
         getimage(x,y,x+10,y+15,p);
		 if(x<600)
			 draw_mouse(x,y);
		 else  ;
         if(x>=400&&x<=440&&y>=350&&y<=390&&button&1==1)
               {closegraph();ko=1;break;}
         else if(x>=400&&x<=440&&y>=300&&y<=340&&button&1==1)
                 {closegraph(); break;}
         else if(x>=230&&x<=390&&y>=300&&y<=340&&button&1==1)
				{closegraph(); break;}
         else if(x>=230&&x<=390&&y>=350&&y<=390&&button&1==1)
				{closegraph();ko=1;break;}
         else if(x>=400&&x<=440&&y>=350&&y<=390)
                 {setcolor(4);outtextxy(400,365,"(S)");}
         else if(x>=400&&x<=440&&y>=300&&y<=340) 
				{setcolor(4); outtextxy(400,315,"(W)");}
         else if(x>=230&&x<=390&&y>=300&&y<=340) 
				{setcolor(4); outtextxy(400,315,"(W)");}
          else if(x>=230&&x<=390&&y>=350&&y<=390)
                 {setcolor(4);outtextxy(400,365,"(S)");}
          else {setcolor(9);outtextxy(400,365,"(S)");outtextxy(400,315,"(W)");
		  }
          
		}
	 }

}
void voice()/*声音*/
{
    char bits;
    union
    {
        int divisor;
        char c[2];
    } countt;
    int i;
    for(i=0; i<100; i++)
    {
        countt.divisor=600;
        outportb(0x43,0xb6);
        outportb(0x42,countt.c[0]);
        outportb(0x42,countt.c[1]);
        bits=inport(0x61);
        outportb(0x61,bits|3);
        delay(500);
        outportb(0x61,bits&0xfc);
        outportb(0x61,bits);
    }
}
void weiye()/*尾页的动画*/
{
    int gdriver=VGA, gmode=VGAHI,a,b,c=1;
    int d[]= {"此","程","序","完","成","于","二","零","二","一","年","四","月","三十","号"},i,e;
    int h,n,z,x,f[]= {"指","导","老","师","","",""},m;
    int g[]= {"感","谢","老","师","的","辛","勤","教","导"};
    int k[]= {"祝","老","师","身","体","健","康","工","作","顺","利"};
    initgraph(&gdriver, &gmode, "");
    cleardevice();
    e=80;
    h=200;
    c=1;
    e=80;
    for(i=1; i<=16; i++)
    {
        disphz3(e,h-120,d[i-1],c,1);
        delay(50000);
        voice();
        c++;
        e+=30;
    }


    m=180;
    c=1;
    for(i=1; i<=7; i++)
    {
        disphz3(m,h-80,f[i-1],c,1);
       delay(50000);
        voice();
        c++;
        m+=30;
    }
  
    n=150;
    c=1;
    for(i=1; i<=9; i++)
    {
        disphz3(n,h-40,g[i-1],c,1);
       delay(50000);
        voice();
        c++;
        n+=30;
    }


    z=120;
    c=1;
    for(i=1; i<=11; i++)
    {
        disphz3(z,h,k[i-1],c,1);
        delay(50000);
        voice();
        c++;
        z+=30;
    }
    
    e=80;
    for(i=1; i<=15; i++)
    {
        disphz3(e,h-120,d[i-1],0,1);
        e+=30;
    }
    m=180;
    for(i=1; i<=7; i++)
    {
        disphz3(m,h-80,f[i-1],0,1);
        m+=30;
    }
    n=150;
    for(i=1; i<=9; i++)
    {
        disphz3(n,h-40,g[i-1],0,1);
        n+=30;
    }
    z=120;
    for(i=1; i<=11; i++)
    {
        disphz3(z,h,k[i-1],0,1);
        z+=30;
    }
    a=240,b=240;
    while(b>=-30)
    {
        disphz3(a,b,"愿我们历尽千帆",14,2);
        disphz3(a,b+30,"归来仍是少年",14,2);
        sleep(1);
        disphz3(a,b,"愿我们历尽千帆",0,2);
        disphz3(a,b+30,"归来仍是少年",0,2);
        b-=20;
    }
    disphz3(400,400,"感谢使用此程序,按任意键退出",3,1);
	over=1;
    getch();
}

int main()
{

      sjm();/*首界面*/
    if(ko==0) 
      lujing();/*按w进入*/  
    if(y==1)/*如果文件能打开,则进行读成绩*/
	{ duchengji();
      jisuan();/*计算用于圆饼图*/
	  tx=1;
	}
    else 
		return 0;
     while(1)/*圆饼图与条形图的切换*/
   {       if(tx==1)/*是否进入条形图*/
          {yb=0;tiaoxingtu();} 
            if(yb==1)/*是否进入圆饼图*/
          {tx=0;over=0;yuanbing();}
          else break;/*按ESC退出*/
           if(over==1)/*尾页完成退出*/
           break;
           if(tx!=1)/*是否进入条形图*/
           break;

    }
 
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值