#include <stdio.h>
void main()
{
int large(int x,int y);
int a[10],b[10],i,n=0,m=0,k=0;
printf("enter array a:\n");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("\n");
printf("enter array b:\n");
for(i=0;i<10;i++)
scanf("%d",&b[i]);
printf("\n");
for(i=0;i<10;i++)
{
if(large(a[i],b[i])==1)
n=n+1;
else if(large(a[i],b[i])==0)
m=m+1;
else k=k+1;
}
printf("a[i]>b[i]%d times\na[i]=b[i]%d times\na[i]<b[i]%d times\n",n,m,k);
if(n>k) printf("array a is larger than array b\n");
else if(n<k) printf("array a is smaller than array b\n");
else printf("array a is equal to array b\n");
}
larger(int x,int y)
{
int flag;
if(x>y) flag=1;
else if(x<y) flag=-1;
else flag=0;
return(flag);
}
比较二个数组的大小:例如a[i]与b[i]比,每次i的值都不一样。比较a 数组大b数组几次,b 数组大a数组几次,相等几次。我运行是内部总有一个错。