fgdfg



#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
struct jilu
{
    char name[10];
    char kong;
    char kind;
    long start;
    char length;
    char xiaoshu;
    char c[14];
} u[4];
struct people
{
    char name1[10];
    double english;
    double math;
    double computer;
    double zongfen;
} x[100],y;
int wenjian(struct people *x)
{
    FILE *fp;
    long jizong,i,j,k,t;
    short touchang,jiluchang;
    char english1[10],math[10],computer[10],hao;
    double xiaoshu;
    fp=fopen("c:\\tc\\aaa.dic","r");
    fseek(fp,4,1);
    fread(&jizong,4,1,fp);
    fread(&touchang,2,1,fp);
    fread(&jiluchang,2,1,fp);
    fseek(fp,32,0);
    for(;;)
    {
        fread(&u[0],32,1,fp);
        if(u[0].name[0]=='n'&&u[0].name[1]=='a'&&u[0].name[2]=='m'&&u[0].name[3]=='e')
            break;
    }
    fseek(fp,32,0);
    for(;;)
    {
        fread(&u[1],32,1,fp);
        if(u[1].name[0]=='e'&&u[1].name[1]=='n'&&u[1].name[2]=='g'&&u[1].name[3]=='l'&&u[1].name[4]=='i'&&u[1].name[5]=='s'&&u[1].name[6]=='h')
            break;
    }
    fseek(fp,32,0);
    for(;;)
    {
        fread(&u[2],32,1,fp);
        if(u[2].name[0]=='m'&&u[2].name[1]=='a'&&u[2].name[2]=='t'&&u[2].name[3]=='h')
            break;
    }
    fseek(fp,32,0);
    for(;;)
    {
        fread(&u[3],32,1,fp);
        if(strcmp(u[3].name,"computer")==0)
            break;




    }
    t=0;
    for(i=0; i<=jizong-1; i++)
    {
        xiaoshu=0;
        fseek(fp,touchang,0);
        fseek(fp,jiluchang*i,1);
        fread(&hao,1,1,fp);
        if(hao=='*')
            continue;
        fseek(fp,u[0].start-1,1);
        fgets(x[t].name1,u[0].length+1,fp);
        for(j=u[0].length-1; j>=0; j--)
        {
            if(x[t].name1[j]==' ')
                x[t].name1[j]=0;
            else
                break;
        }
        fseek(fp,-u[0].start-u[0].length,1);
        fseek(fp,u[1].start,1);
        fgets(english1,u[1].length+1,fp);
        x[t].english=atof(english1);
        fseek(fp,-u[1].start-u[1].length,1);
        fseek(fp,u[2].start,1);
        fgets(math,u[2].length+1,fp);
        x[t].math=atof(math);
        fseek(fp,-u[2].start-u[2].length,1);
        fseek(fp,u[3].start,1);
        fgets(computer,u[3].length+1,fp);
        x[t].computer=atof(computer);
        x[t].zongfen=x[t].english+x[t].math+x[t].computer;
        t++;
    }
    for(i=0; i<=t-2; i++)
    {
        k=i;
        for(j=i+1; j<=t-1; j++)
            if(x[k].zongfen<x[j].zongfen)
                k=j;
        y=x[k];
        x[k]=x[i];
        x[i]=y;
    }
    for(j=0; j<=t-2; j++)
        if(x[j].zongfen==x[j+1].zongfen)
        {
            if(x[j].english<x[j+1].english)
                y=x[j],x[j]=x[j+1],x[j+1]=y;
            if(x[j].english==x[j+1].english)
            {
                if(x[j].computer<x[j+1].computer)
                    y=x[j],x[j]=x[j+1],x[j+1]=y;
            }
        }
    fclose(fp);
    return t;
}
int huatu(struct people *x,int t)
{
    union
    {
        int key;
        char c[2];
    } m;
    int i,b,c,j,d=1,e=1,k;
    char p;
    int gdriver=VGA, gmode=VGAHI;
    initgraph(&gdriver, &gmode, "");
    cleardevice();
    for(k=0; k<=t-1; )
    {
        b=70;
        c=100;
        line(70,440,600,440);
        line(600,440,590,430);
        line(600,440,590,450);
        line(70,20,70,440);
        line(70,20,60,30);
        line(70,20,80,30);
        if(k==0)
        {
            setfillstyle(1,2),bar3d(150,460,170,470,10,1);
            outtextxy(160,465,"P");
        }
        else
        {
            setfillstyle(1,1),bar3d(150,460,170,470,10,1);
            outtextxy(160,465,"P");
        }
        if(k==t-1)
        {
            setfillstyle(1,2),bar3d(350,460,370,470,10,1);
            outtextxy(360,465,"N");
        }
        else
        {
            setfillstyle(1,1),bar3d(350,460,370,470,10,1);
            outtextxy(360,465,"N");
        }
        setfillstyle(1,1),bar3d(550,460,570,470,10,1);
        outtextxy(560,465,"X");
        outtextxy(600,445,"y");
        outtextxy(60,10,"x");
        outtextxy(72,442,"o");
        outtextxy(72,400,"10");
        outtextxy(72,360,"20");
        outtextxy(72,320,"30");
        outtextxy(72,280,"40");
        outtextxy(72,240,"50");
        outtextxy(72,200,"60");
        outtextxy(72,160,"70");
        outtextxy(72,120,"80");
        outtextxy(72,80,"90");
        outtextxy(72,40,"100");
        for(i=0; i<=2; i++)
        {
            if(i+k>t-1)
                break;
            if(i>=1)
                b+=40,c+=40;
            for(j=0; j<=2; j++)
            {
                b+=30;
                c+=30;
                if(j==0)
                    setfillstyle(d,1),bar3d(b,440-(long)(x[i+k].english*4),c,440,20,1);
                if(j==1)
                    setfillstyle(d,2),bar3d(b,440-(long)(x[i+k].math*4),c,440,20,1);
                if(j==2)
                    setfillstyle(d,3),bar3d(b,440-(long)(x[i+k].computer*4),c,440,20,1);




            }
            setfillstyle(d,1);
            bar(500,40,540,60);
            outtextxy(545,40,"english");
            setfillstyle(d,2);
            bar(500,60,540,80);
            outtextxy(545,60,"math");
            setfillstyle(d,3);
            bar(500,80,540,100);
            outtextxy(545,80,"computer");
            outtextxy(c-45,445,x[i+k].name1);
        }
        m.key=bioskey(0);
        if((m.c[0]=='p'||m.c[0]=='P')&&k>=3)
            k-=3;
        if((m.c[0]=='n'||m.c[0]=='N')&&k<=t-4)
            k+=3;
        if(m.c[0]=='x'||m.c[0]=='X')
            break;
        cleardevice();
    }
    closegraph();
    return 0;
}
void huatu2 (struct people *p,int x)
{
    int a=0,b=0,c=0,d=0,e=0,f=0,i;
    int gdriver=VGA,gmode=VGAHI;
    initgraph(&gdriver,&gmode,"");
    for(i=0; i<x; i++)
    {
        if(p[i].zongfen/3<60)
            e++;
        if(p[i].zongfen/3>=60&&p[i].zongfen/3<70)
            d++;
        if(p[i].zongfen/3>=70&&p[i].zongfen/3<80)
            c++;
        if(p[i].zongfen/3>=80&&p[i].zongfen/3<90)
            b++;
        if(p[i].zongfen/3>=90)
            a++;
    }
    setfillstyle(1,RED);
    pieslice(320,240,0,3600*(a*0.1/x),100);
    setfillstyle(1,BLUE);
    pieslice(320,240,3600*(a*0.1/x),3600*(a*0.1/x)+3600*(b*0.1/x),100);
    setfillstyle(1,GREEN);
    pieslice(320,240,3600*(a*0.1/x)+3600*(b*0.1/x),3600*(a*0.1/x)+3600*(b*0.1/x)+3600*(c*0.1/x),100);
    setfillstyle(1,YELLOW);
    pieslice(320,240,3600*(a*0.1/x)+3600*(b*0.1/x)+3600*(c*0.1/x),3600*(a*0.1/x)+3600*(b*0.1/x)+3600*(c*0.1/x)+3600*(d*0.1/x),100);
    setfillstyle(1,WHITE);
    pieslice(320,240,3600*(a*0.1/x)+3600*(b*0.1/x)+3600*(c*0.1/x)+3600*(d*0.1/x),3600*(a*0.1/x)+3600*(b*0.1/x)+3600*(c*0.1/x)+3600*(d*0.1/x)+3600*(e*0.1/x),100);
    getch();
    closegraph();
}
void huatu3()
{
    union
    {
        int key;
        char c[2];
    } m;
    int gdriver=DETECT, gmode,a,b,i;
    initgraph(&gdriver, &gmode, "");
    cleardevice();
    setfillstyle(1,15);
    bar(100,100,300,150);
    a=110;
    b=140;
    setfillstyle(1,0);
    line(a,140,a+10,b);
    getch();
    setfillstyle(1,15);
    line(a,140,a+10,b);
    m.key=bioskey(0);
    if(m.key!=NULL)
    {
        if(('a'<=m.c[1]&&m.c[1]<='z')||('A'<=m.c[1]&&m.c[1]<='Z'))
        {
            outtextxy(a,b,"m.c[1]");
            setfillstyle(1,0);
            line(a,140,a+10,b);
            a+=5;
        }


    }










    getch();
}
int newxy(int *mx,int *my,int *mbutt)
{
    int ch,xx0=*mx,yy0=*my;
    int xm,ym;
    ch=read_mouse(&xm,&ym,mbutt);
    cursor(xx0,yy0);
    cursor(xm,ym);
}
void huatu4()
{
    int gdriver=DETECT, gmode,a,b,i,x,y,x1,y1,buttons;
    initgraph(&gdriver, &gmode, "");
    cleardevice();
    circle(320,240,10);
    x=fat gety();
    y=far gety();
    far moverel(320-x,240-y);
    x1=320;
    y1=240;
    for(;;)
    {
        newxy(&x1,&y1,&buttons);
        
    }
}
int main()
{
    int b,c;
    /*b=wenjian(x);读文件*/
    /*c=huatu(&x[0],b)画翻页;
    if(c==0)
        huatu2(&x[0],b);饼图*/
    /*huatu3();画光标闪烁*/
    huatu4();
    return 0;
}

猜你喜欢

转载自blog.csdn.net/najiuzheyangbaacm/article/details/80320536
ffg
fgf
fdg
fdf
今日推荐