拜托找出程序是哪里不对?
程序代码:
该程序是找出a数组在与b数组对比中,输出有相同四码的数组。但输出的不对问题出在哪?敬请指点!!! #include<stdio.h> int b[10000][5]; int zbbhj_x; void xdu373zhZ(int a[][5],int zbbhj_x); int ybbhj_ch; void xdu374zhZ(int b[][5],int ybbhj_ch); void xshan372zhZ(int a[][5],int zbbhj_x); int zybbhj_ok2; void main() { int a[10000][5]; zbbhj_x=7082; xdu373zhZ(a,zbbhj_x); ybbhj_ch=703; xdu374zhZ(b,ybbhj_ch); xshan372zhZ(a,zbbhj_x); printf("zybbhj_ok2=%d",zybbhj_ok2); printf("\n"); } void xdu373zhZ(int a[][5],int zbbhj_x)// { int i,j; FILE *pf; if((pf=fopen("e:\\zFILE522.txt","r"))==NULL) { printf("Cannot open file!"); return; } for(i=0;i<zbbhj_x;i++) for(j=0;j<5;j++) { fscanf(pf,"%4d",&a[i][j]); fscanf(pf,"\n"); } fclose(pf); } void xdu374zhZ(int b[][5],int ybbhj_ch)// { int i,j; FILE *pf; if((pf=fopen("e:\\FILE522.txt","r"))==NULL) { printf("Cannot open file!"); return; } for(i=0;i<ybbhj_ch;i++) for(j=0;j<5;j++) { fscanf(pf,"%4d",&b[i][j]); fscanf(pf,"\n"); } fclose(pf); } void xshan372zhZ(int a[][5],int zbbhj_x) { int i,j,counter,s,sum; FILE *pf; if((pf=fopen("e:\\FILE522_shu.txt","w"))==NULL) { printf("Cannot open file!"); return; } for(i=0;i<zbbhj_x;i++) { sum=0; for(s=0;s<ybbhj_ch;s++) { counter=0; for(j=0;j<5;j++) { if(b[s][j]==a[i][j]) counter++; if(counter==4) /*如4个号码相同,将赋值给sum*/ sum=counter; } } if(sum==4) { for(j=0;j<5;j++) fprintf(pf,"%4d",a[i][j]); fprintf(pf,"\n"); zybbhj_ok2++; } } fclose(pf); }