persentation error
s.ali.jafari · 2015-04-12 15:03:02
include include <math.h>using namespace std;
int main() { int n,a[20],i,p,q; while(1) { i=0; a[i]=0; cin>>n; while(n) { i++; cin>>a[i]; if(a[i]>=5280||n>=5280)break; p=fabs(a[i-1]-n); q=fabs(a[i]-n); cout<<"Moving from "<<a[i-1]<<" to "<<a[i]; if(n==a[i]) cout<<": found it!\n"; if(n==a[i])break;
else if(p==q)
cout<<": same.\n";
else if(p<q)
cout<<": colder.\n";
else if(p>q)
cout<<": warmer.\n";
}
if(a[i]>=5280||n>=5280||n==a[i])break;
}
return 0;
}
s.ali.jafari · 2015-04-12 15:03:47
hi, can u please check my code?
every time i submit it shows persentation error!!!
AMiR · 2015-04-13 20:19:51
ali 3571 said:
hi, can u please check my code?
every time i submit it shows persentation error!!!
Please read all the answers on the topic.
You need to put exactly on extra newline between each test.
My suggestion is to put the input in a file, like in.txt and run your code from command line like this:
g++ a.cpp -O2
./a.out < in.txt > out.txt
It will redirect the content of the in.txt into your STDIN and it does the same for our STDOUT. You can check the content of out.txt and see what is going wrong.
- 1
- 2