what is test 3 Posted by garra 20 Jan 2012 18:49 Re: what is test 3 Hi, better post your code, it's faster to find a mistake. Re: what is test 3 Posted by garra 20 Jan 2012 21:57 i got past that now i am stuck at test 9 Re: what is test 3 Posted by garra 20 Jan 2012 21:58 int main() { int a1[4000],b1[4000],c1[4000],g1[4000],g2[4000],a,b,c,i,j,k=0,m,n=0; scanf("%d",&a); for(i=0;i<a;i++) { scanf("%lu",&a1[i]); } scanf("%d",&b); for(i=0;i<b;i++) { scanf("%lu",&b1[i]); } scanf("%d",&c); for(i=0;i<c;i++) { scanf("%lu",&c1[i]); } for(i=0;i<a;i++) { for(j=0;j<b;j++) { if(a1[i]==b1[j]) { g1[k]=a1[i]; k++; } } for(m=0;m<c;m++) { if(a1[i]==c1[m]) { g2[n]=c1[m]; n++; } } } if(n>=k) { printf("%d",k); } else { printf("%d",n); } return 0; } i got past that now i am stuck at test 9 Re: what is test 3 Posted by garra 20 Jan 2012 21:58 int main() { int a1[4000],b1[4000],c1[4000],g1[4000],g2[4000],a,b,c,i,j,k=0,m,n=0; scanf("%d",&a); for(i=0;i<a;i++) { scanf("%lu",&a1[i]); } scanf("%d",&b); for(i=0;i<b;i++) { scanf("%lu",&b1[i]); } scanf("%d",&c); for(i=0;i<c;i++) { scanf("%lu",&c1[i]); } for(i=0;i<a;i++) { for(j=0;j<b;j++) { if(a1[i]==b1[j]) { g1[k]=a1[i]; k++; } } for(m=0;m<c;m++) { if(a1[i]==c1[m]) { g2[n]=c1[m]; n++; } } } if(n>=k) { printf("%d",k); } else { printf("%d",n); } return 0; } i got past that now i am stuck at test 9 Re: what is test 3 You solution doesn't seem to be right. As far as I see, you have in g1 the common values from A and B, and in g2 the common values from A and C. Then, you output the size of the smaller array (g1 or g2). This is not correct, as you don't intersect B with C. Here's a counter-example: 5 2 3 4 5 6 5 3 4 5 6 7 5 1 2 3 4 5 Your output is 4 but correct is 3. Edited by author 21.01.2012 04:48 Edited by author 21.01.2012 04:49 Re: what is test 3 Posted by garra 21 Jan 2012 17:46 thank you morbidel Re: what is test 3 Edited by author 19.04.2012 05:39 |