|
|
back to boardPlease help!!!! Please help!!!Tell me what is wrong in my algo???Help to orgonise input!Here is my code: #include <iostream.h> int main() { const int N=50000; int x[N],y[N]; bool s; int i,k; int a,b; cin>>a; for(i=0;i<a;i++) { cin>>x[i]; } cin>>b; for(i=0;i<b;i++) { cin>>y[i]; } for(i=0;i<a;i++) { for(k=0;k<b;k++) { if(x[i]+y[k]==10000) { s=true; } if(x[i]+y[i]!=10000) { s=false; } } } if(s=true) { cout<<"YES"<<endl; } if(s=false) { cout<<"NO"<<endl; } return 0; } Re: Please help!!!! Posted by melkiy 10 Nov 2009 21:53 You must finish your iterations and print "YES", if an appropriate pair of numbers is found. Now your program outputs the value of the 's' for the last pair, x[a-1] and y[b-1]. But this algo can be substantially optimized. |
|
|