一直报错不知道问题在哪

第一次遇见这个错误,不知道该咋办,求解答
不知道是yuanbing函数有啥问题

img

#include<stdlib.h>
#include<graphics.h>
#include<string.h>
#include<stdio.h>
#include<dos.h>
#define HZK "c:\\tc\\hzk16f"
#define S 16
typedef struct
{
    char biaozhi;
    char time[3];
    long jlzs;
    short zcd;
    short jlcd;
    char empty[20];
}HEAD;
typedef struct
{
    char name[10];
    char c;
    char lx;
    long whizhi;
    char zdcd;
    char xswsd;
    char empty[14];
}E;
typedef struct
{
    char name[15];
    float math;
    float english;
    float computer;
    float zf;
        float average;
}F;
E e[5];
F f[10],t;
void huiTu(int n2)        
{
    int i;
    char* k1 = "数学";
    char* k2 = "计算机";
    char* k3 = "英语";
    int q = 170;
    cleardevice();
    line(50, 340, 550, 340);
    line(550, 340, 540, 335);
    line(550, 340, 540, 345);
    outtextxy(550, 350, "x");
    line(120, 50, 120, 400);
    line(120, 50, 125, 60);
    line(120, 50, 115, 60);
    outtextxy(130, 40, "y");
    outtextxy(125, 345, "0");
    setcolor(13);
    rectangle(480, 0, 630, 90);
    setcolor(15);
    rectangle(490, 10, 520, 30);
    setfillstyle(1, 6);
    floodfill(495, 15, 15);
    setcolor(15);
    rectangle(490, 35, 520, 55);
    setfillstyle(1, 9);
    floodfill(495, 40, 15);
    setcolor(15);
    rectangle(490, 60, 520, 80);
    setfillstyle(1, 12);
    floodfill(495, 65, 15);
    setcolor(15);
    hzfd(530, 15, k1, 6, 1);
    hzfd(530, 40, k2, 9, 1);
    hzfd(530, 65, k3, 12, 1);
line(120, 300, 130, 300);
    line(120, 260, 130, 260);
    line(120, 220, 130, 220);
    line(120, 180, 130, 180);
    line(120, 140, 130, 140);
    outtextxy(100, 300, "20");
    outtextxy(100, 260, "40");
    outtextxy(100, 220, "60");
    outtextxy(100, 180, "80");
    outtextxy(95, 140, "100");
    for (i= 0; i <n2; i++)
    {
        hzfd(q, 350, f[i].name, 15, 1);
        setcolor(15);
        bar3d(q, f[i].english* (-2) + 340, q + 10, 340, 10, 1);
        if (f[i].english!= 0)
        {
            setfillstyle(1, 6);
            floodfill(q + 5, f[i].english* (-2) + 340 + 5, 15);
            setfillstyle(1, 6);
            floodfill(q + 5, f[i].english* (-2) + 340 - 2, 15);
            setfillstyle(1, 6);
            floodfill(q + 15, f[i].english* (-2) + 340 + 5, 15);
        };
        bar3d(q + 10, f[i].math * (-2) + 340, q + 20, 340, 10, 1);
        if (f[i].math != 0)
        {
            setfillstyle(1, 9);
            floodfill(q + 15, f[i].math * (-2) + 340 + 5, 15);
            setfillstyle(1, 9);
            floodfill(q + 15, f[i].math * (-2) + 340 - 2, 15);
            setfillstyle(1, 9);
            floodfill(q + 22, f[i].math * (-2) + 340 + 5, 15);
        };
        bar3d(q + 20, f[i].computer * (-2) + 340, q + 30, 340, 10, 1);
        if (f[i].computer != 0)
        {
            setfillstyle(1, 12);
            floodfill(q + 25, f[i].computer * (-2) + 340 + 5, 15);
            setfillstyle(1, 12);
            floodfill(q + 25, f[i].computer * (-2) + 340 - 2, 15);
            setfillstyle(1, 12);
            floodfill(q + 32, f[i].computer * (-2) + 340 + 5, 15);
        };
         q = 150 + q;
         if((i+1)%3==0)
        {
         getch();
         clearviewport();
         q=170;
         line(50, 340, 550, 340);
         line(550, 340, 540, 335);
         line(550, 340, 540, 345);
         outtextxy(550, 350, "x");
         line(120, 50, 120, 400);
         line(120, 50, 125, 60);
         line(120, 50, 115, 60);
         outtextxy(130, 40, "y");
         outtextxy(125, 345, "0");
         setcolor(13);
rectangle(480, 0, 630, 90);
         setcolor(15);
         rectangle(490, 10, 520, 30);
         setfillstyle(1, 6);
         floodfill(495, 15, 15);
         setcolor(15);
         rectangle(490, 35, 520, 55);
         setfillstyle(1, 9);
         floodfill(495, 40, 15);
         setcolor(15);
         rectangle(490, 60, 520, 80);
        setfillstyle(1, 12);
        floodfill(495, 65, 15);
        setcolor(15);
        hzfd(530, 15, k1, 6, 1);
        hzfd(530, 40, k2, 9, 1);
        hzfd(530, 65, k3, 12, 1);
        line(120, 300, 130, 300);
        line(120, 260, 130, 260);
        line(120, 220, 130, 220);
        line(120, 180, 130, 180);
        line(120, 140, 130, 140);
        outtextxy(100, 300, "20");
        outtextxy(100, 260, "40");
        outtextxy(100, 220, "60");
        outtextxy(100, 180, "80");
        outtextxy(95, 140, "100");
        }
    }          
}
int hzfd(int x, int y, char* p, int color, int m)                       
{
    int  i, j, n, k;
    FILE* fp;
    char qh, wh;
    long offset;
    char buffer[S * S / 8];
    char mask[] = { 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01 };
    if ((fp = fopen(HZK, "rb")) == NULL)
        exit(0);
    while (*p != '\0')
    {
        qh = *p - 0xa0;
        p++;
        wh = *p - 0xa0;
        p++;
        offset = (94L * (qh - 1) + wh - 1) * S * S / 8;
        fseek(fp, offset, 0);
        fread(buffer, S * S / 8, 1, fp);
        for (i = 0; i < S; i++)
        {
            for (j = 0; j < S; j++) 
            {
                if ((buffer[S / 8 * i + j / 8] & mask[j % 8]) != 0)
                    for (n = 0; n < m; n++)
                        for (k = 0; k < m; k++)
                            putpixel(x + j * m + n, y + i * m + k, color);
            }
        }
        x += S * m + 5;
    }
    fclose(fp);
}
int yuanbing(n2)
{    
        int a,d,f,s,g,rad[5]={0},i;
    cleardevice();
    
        a=s=d=f=g=0;
        for(i=0;i<n2;i++)
        {
            if(f[i].average >=90)
                g++;
            if (f[i].average >=80 && f[i].average <90)
                s++;
            if (f[i].average >=70 && f[i].average <80)
                f++;
            if (f[i].average >=60 && f[i].average <70)
                d++;
            if (f[i].average > =0 && f[i].average <=59)
                a++;    
        }
        for(i=0;i<5;i++)
        {
            if(i==0)
            rad[i]=a*1.0/n2*360;
            if(i==1)
            rad[i]=d*1.0/n2*360;
            if(i==2)
            rad[i]=f*1.0/n2*360;
            if(i==3)
            rad[i]=s*1.0/n2*360;
            if(i==4)
            rad[i]=g*1.0/n2*360;
        }
        cleardevice();
        if(a!=0)
        {
        
        setfillstyle(1, 2);
        pieslice(320,240,0,rad[0],150);
        }
        if(d!=0)
        {
        
        setfillstyle(1, 4);
        pieslice(320,240,rad[0],rad[0]+rad[1],150);
        }
        if(f!=0)
        {
        
        setfillstyle(1, 6);
        pieslice(320,240,rad[0]+rad[1],rad[0]+rad[1]+rad[2],150);
        }
        if(s!=0)
        {
        
        setfillstyle(1, 8);
        pieslice(320,240,rad[0]+rad[1]+rad[2],rad[0]+rad[1]+rad[2]+rad[3],150);
        }
        if(g!=0)
        {
        setfillstyle(1, 10);
        pieslice(320,240,rad[0]+rad[1]+rad[2]+rad[3],rad[0]+rad[1]+rad[2]+rad[3]+rad[4],150);
        }
        setcolor(15);
        rectangle(500, 10, 550, 30);
        setfillstyle(1, 2);
        floodfill(540, 20, 15);
        setcolor(15);
        rectangle(500, 40, 550, 60);
        setfillstyle(1, 4);
        floodfill(540, 50, 15);
        setcolor(15);
        rectangle(500, 70, 550, 90);
        setfillstyle(1, 6);
        floodfill(540, 80, 15);
        setcolor(15);
        rectangle(500, 100, 550, 120);
        setfillstyle(1, 8);
        floodfill(540, 110, 15);
        setcolor(15);
        rectangle(500, 130, 550, 150);
        setfillstyle(1, 10);
        floodfill(540, 140, 15);
        outtextxy(570, 20, "90-");
        outtextxy(570, 50, "80-89");
        outtextxy(570, 80, "70-79");
        outtextxy(570, 110, "60-69");
        outtextxy(570, 140, "0-59");
        return 0;
}
void movetoxy(int x,int y)
{
union REGS regs;
regs.h.ah=2;
regs.h.dh=y;
regs.h.dl=x;
regs.h.bh=0;
int86(0x10,&regs,&regs);
}
int main()
{
        int gdriver=DETECT,mode;
        HEAD head;
        int i,j,n,n1,n2=0;
    char name[15],fen[15],flag,fname[15],a0[7],a1[7],a2[7],a3[7],a4[7];
    FILE *p;
char *p0="综";
char *p1="合";
char *p2="应";
char *p3="用";
char *p4="程序功能:";
char *p5="一。显示学生成绩直方图";
char *p6="二。展示各分段圆饼图";
char *p7="按任意键继续";

char *p8="请输入数据库文件名,回车键结束:";
char *p9="提示:";
char *p10="一。可以带盘符和路径,如:";
char *p11="二。";
char *p12="可以省略";

char *p13="学生成绩示意图";
char *p14="数学";
char *p15="计算机";
char *p16="英语";

initgraph(&gdriver,&mode,"");
setcolor(2);
rectangle(120,100,520,380);
setfillstyle(1,2);
floodfill(320,240,2);
setcolor(12);
rectangle(180,240,460,380);
setfillstyle(1,12);
floodfill(320,290,12);
setcolor(1);
setfillstyle(1,1);
circle(320,180,30);
floodfill(320,180,1);
circle(260,180,30);
floodfill(260,180,1);
circle(200,180,30);
floodfill(200,180,1);
circle(380,180,30);
floodfill(380,180,1);
circle(440,180,30);
floodfill(440,180,1);
setcolor(15);
settextstyle(1,0,7);
settextjustify(1,1);
outtextxy(200,175,"C");
hzfd(235,155,p0,15,3);
hzfd(298,155,p1,15,3);
hzfd(355,155,p2,15,3);
hzfd(415,155,p3,15,3);
hzfd(250,250,p4,10,1);
hzfd(250,275,p5,10,1);
hzfd(250,300,p6,10,1);
hzfd(280,325,p7,1,1);
getch();
cleardevice();

hzfd(170,195,p8,15,1);
setcolor(WHITE);
rectangle(170,215,470,240);
setfillstyle(1,WHITE);
floodfill(175,225,WHITE);
hzfd(170,240,p9,RED,1);
hzfd(200,260,p10,RED,1);
hzfd(200,280,p11,RED,1);
hzfd(255,280,p12,RED,1);
setcolor(9);
settextstyle(0,0,1);
settextjustify(0,0);
outtextxy(460,270,"c: \ tc \ ss.dbf");
outtextxy(210,290,".dbf");
movetoxy(150,167);


scanf("%s",fname);
        p=fopen(fname,"rb");
    if(p==NULL)
    printf("1");

        printf("1");
    fread(&head,32,1,p);
    n1=(head.zcd-33)/32;
    for(i=0;i<head.jlzs;i++)
    {
        fread(e,32,1,p);
        if(strcmp(e[0].name,"姓名")==0)
        e[1]=e[0];
        if(strcmp(e[0].name,"数学")==0)
        e[2]=e[0];
        if(strcmp(e[0].name,"英语")==0)
        e[3]=e[0];
        if(strcmp(e[0].name,"计算机")==0)
        e[4]=e[0];
    }
    for(j=0;j<head.jlzs;j++)
    {
        fseek(p,head.zcd,0);
        fseek(p,j*head.jlcd,1);
        fread(&flag,1,1,p);
        fseek(p,-1,1);
        if(flag=="*")
        {
            continue;
        }
        fseek(p,e[1].whizhi,1);
        fread(name,e[1].zdcd,1,p);
        name[e[1].zdcd]=0;
        for(i=e[1].zdcd-1;i>=0;i--)
        {
            if(name[i]==" ")
            name[i]=0;
            else
            break;
        }
        strcpy(f[n2].name,name);

        fseek(p,head.zcd,0);
        fseek(p,j*head.jlcd,1);
        fseek(p,e[2].whizhi,1);
        fread(fen,e[2].zdcd,1,p);
        f[n2].math=(float)atof(fen);

        fseek(p,head.zcd,0);
        fseek(p,j*head.jlcd,1);
        fseek(p,e[3].whizhi,1);
        fread(fen,e[3].zdcd,1,p);
        f[n2].english=(float)atof(fen);

        fseek(p,head.zcd,0);
        fseek(p,j*head.jlcd,1);
        fseek(p,e[4].whizhi,1);
        fread(fen,e[4].zdcd,1,p);
        f[n2].computer=(float)atof(fen);
        f[n2].zf=f[n2].math+f[n2].english+f[n2].computer;
                f[n2].average=f[n2].zf/3.0;
        n2++;
    }
    for(j=0;j<n2;j++)
    for(i=0;i<n2;i++)
    {
    if(f[i].zf<f[i+1].zf)
    {
        t=f[i];
        f[i]=f[i+1];
        f[i+1]=t;
    }
    if(f[i].zf==f[i+1].zf)
    {
        if(f[i].english<f[i+1].english)
        {
            t=f[i];
            f[i]=f[i+1];
            f[i+1]=t;
        }
    }
    }
cleardevice();
getch();
huiTu(n2);
getch();
cleardevice();
yuanbing(n2);    
getch();    
closegraph();
return 0;
}






这个错误发生在 int yuanbing(n2) 函数里,函数形参语法错误,函数里定义了变量 f 和全局数组变量f[10] 重名, int yuanbing() 修改如下,改动处见注释,供参考:

int yuanbing(int n2)  // 修改  int yuanbing(n2) 
{
    int a, d, ff, s, g, rad[5] = { 0 }, i;  // f  修改
    cleardevice();

    a = s = d = ff = g = 0;   // 修改 f
    for (i = 0; i < n2; i++)
    {
        if (f[i].average >= 90)
            g++;
        if (f[i].average >= 80 && f[i].average < 90)
            s++;
        if (f[i].average >= 70 && f[i].average < 80)
            ff++; // 修改  f
        if (f[i].average >= 60 && f[i].average < 70)
            d++;
        if (f[i].average >= 0 && f[i].average <= 59)  // 修改 
            //if (f[i].average > = 0 && f[i].average <= 59)
            a++;
    }
    for (i = 0; i < 5; i++)
    {
        if (i == 0)
            rad[i] = a * 1.0 / n2 * 360;
        if (i == 1)
            rad[i] = d * 1.0 / n2 * 360;
        if (i == 2)
            rad[i] = ff * 1.0 / n2 * 360; // 修改 f
        if (i == 3)
            rad[i] = s * 1.0 / n2 * 360;
        if (i == 4)
            rad[i] = g * 1.0 / n2 * 360;
    }
    cleardevice();
    if (a != 0)
    {

        setfillstyle(1, 2);
        pieslice(320, 240, 0, rad[0], 150);
    }
    if (d != 0)
    {

        setfillstyle(1, 4);
        pieslice(320, 240, rad[0], rad[0] + rad[1], 150);
    }
    if (f != 0)
    {

        setfillstyle(1, 6);
        pieslice(320, 240, rad[0] + rad[1], rad[0] + rad[1] + rad[2], 150);
    }
    if (s != 0)
    {

        setfillstyle(1, 8);
        pieslice(320, 240, rad[0] + rad[1] + rad[2], rad[0] + rad[1] + rad[2] + rad[3], 150);
    }
    if (g != 0)
    {
        setfillstyle(1, 10);
        pieslice(320, 240, rad[0] + rad[1] + rad[2] + rad[3], rad[0] + rad[1] + rad[2] + rad[3] + rad[4], 150);
    }
    setcolor(15);
    rectangle(500, 10, 550, 30);
    setfillstyle(1, 2);
    floodfill(540, 20, 15);
    setcolor(15);
    rectangle(500, 40, 550, 60);
    setfillstyle(1, 4);
    floodfill(540, 50, 15);
    setcolor(15);
    rectangle(500, 70, 550, 90);
    setfillstyle(1, 6);
    floodfill(540, 80, 15);
    setcolor(15);
    rectangle(500, 100, 550, 120);
    setfillstyle(1, 8);
    floodfill(540, 110, 15);
    setcolor(15);
    rectangle(500, 130, 550, 150);
    setfillstyle(1, 10);
    floodfill(540, 140, 15);
    outtextxy(570, 20, "90-");
    outtextxy(570, 50, "80-89");
    outtextxy(570, 80, "70-79");
    outtextxy(570, 110, "60-69");
    outtextxy(570, 140, "0-59");
    return 0;
}

根据代码中的内容,你应该是在使用 Turbo C 编译器进行编译和运行该程序。由于 Turbo C 编译器在 Windows 10 操作系统下可能不再兼容,所以你需要使用兼容的编译器来编译该代码。

建议你使用更现代的编译器,如 Code::Blocks、Dev-C++、MinGW 或 Visual Studio 等,来编译和运行这段代码。这些编译器对 Windows 10 操作系统更加兼容,并提供更好的功能和支持。

另外,上述代码还使用了过时的 DOS 图形库 graphics.h 和其他 DOS 相关的函数,这些函数在现代操作系统中可能不再被支持。当然了,你也可以考虑使用其他图形库(如 SDL、OpenGL 或 Qt)来替代使用 DOS 图形库。

改用VS2022调用easyx库