程序错在哪里该怎么修改?多谢
求助:该程序是a数组与b数组比较,如有相同四码的就把b数组的数码全部赋于a数组并输出,如没有相同四码的就输出a数组。下边的程序有两组数输出的不对:既2 4 6 11 18 应输出是:2 4 6 11 12 却输出了:2 4 5 11 12
1 3 6 11 18 应输出是:1 3 6 9 18 和 1 3 6 11 12 却只输出了:1 3 6 9 18
请拜托解答。多谢啦!!!
程序代码:
#include<stdio.h> void main() { int i,j,s,AA,OKKO; int a[14][5]={ {3,5,6,11,18}, {2,5,6,11,18}, {1,5,6,11,18}, {2,4,6,11,18}, {1,3,6,11,18}, {4,6,8,10,18}, {2,4,7,10,18}, {3,4,5,10,18}, {2,4,5,10,18}, {1,4,5,10,18}, {2,3,5,10,18}, {1,2,5,10,18}, {3,5,7,9,18}, {1,3,6,9,18}, }; int b[14][5]={ {1,3,6,9,18}, {6,7,9,11,12}, {4,7,9,11,12}, {2,7,9,11,12}, {1,7,9,11,12}, {3,7,8,11,12}, {2,5,8,11,12}, {1,5,8,11,12}, {2,4,6,11,12}, {1,3,6,11,12}, {2,4,5,11,12}, {3,6,8,10,12}, {3,6,8,10,11}, {3,6,8,9,13}, }; for(i=0;i<14;i++) { for(s=0;s<14;s++) { AA=0; for(j=0;j<5;j++) { if(b[s][j]==a[i][j])//a数组和b数组对比 AA++; //有相同的就记数 if(AA>=4) { for(j=0;j<5;j++) a[i][j]=b[s][j];//数组中有等于大于四个数码的将b数组的码全部赋予a数组 } } } { for(j=0;j<5;j++) printf("%4d",a[i][j]); printf("\n"); OKKO++; } } }