pages:
- 1
Daneshvar Amrollahi SAYS
Hi. Anybody knows why am I getting wrong answer? This is my code:
include
using namespace std;
int absv(int x) { if (x<0) return x*(-1); else return x; }
int main() { int n,a[10000]; int now,later; cin>>n; while ( true ) { if (n==5280) return 0;
int j = 0;
while (cin>>a[j])
{
if (a[j]==n)
break;
j++;
}
now = 0;
later = a[0];
cout<<"Moving from 0 to "<<a[0];
if (absv(later-n)==absv(now-n))
cout<<": same."<<endl;
if (absv(later-n)>absv(now-n))
cout<<": colder."<<endl;
if (absv(later-n)<absv(now-n))
cout<<": warmer."<<endl;
for (int i=0;i<j;i++)
{
now = a[i];
later = a[i+1];
cout<<"Moving from "<<now<<" to "<<later;
if (i==j-1)
{
cout<<": found it!"<<endl;
break;
}
if (absv(later-n)==absv(now-n))
cout<<": same."<<endl;
if (absv(later-n)>absv(now-n))
cout<<": colder."<<endl;
if (absv(later-n)<absv(now-n))
cout<<": warmer."<<endl;
}
cin>>n;
if (n==5280)
return 0;
cout<<endl;
}
return 0;
}
AMiR SAYS
You print warmer
insteaf of found it
somewhere in the test data's output.
You can check my solution here http://sharecode.ir/discussion/problemset/topic/47
Daneshvar Amrollahi SAYS
AMiR said:
You print
warmer
insteaf offound it
somewhere in the test data's output.You can check my solution here http://sharecode.ir/discussion/problemset/topic/47
Thanks. I got it.
Login please!
In order to post something you must login first. You can use the form in the top of this page.