In these if statements there are absent external parentheses
for (int i=1;i<=m;i++) if (A[i]>minim) && (A[i]<maxim) nn1++; for (int j=1;j<=n;j++) if (B[j]>minim) && (B[j]<maxim) nn2++;
I think that there should be
for (int i=1;i<=m;i++) if ( (A[i]>minim) && (A[i]<maxim) ) nn1++; for (int j=1;j<=n;j++) if ( (B[j]>minim) && (B[j]<maxim) ) nn2++;
And the loops look suspeciously. Take into account that array indices start from 0. So for example if you have an array of size N
then the valid range of indices is [0, N-1]
And you forgot to initialize nn1
and nn2
.
It seems that you mean the following
int nn1 = 0, nn2 = 0; for ( int i = 0; i < m; i++ ) { if ( ( A[i] > minim ) && ( A[i] < maxim ) ) nn1++; } for ( int i = 0; i < n; i++ ) { if ( ( B[i] > minim ) && ( B[i] < maxim ) ) nn2++; } if ( nn1 > nn2 ) cout << "1"; else if ( nn1 < nn2 ) cout << "2"; else cout << "0";