#include<iostream>
#include<string>
#include<cmath>
using namespace std;
string status(int*, int Pos, int i);
const int end = 5280; // no more input if the first input is end
const int size = 21;
int main() {
int cookiePos, a[size], isBetween = -1;
while(cin >> cookiePos && cookiePos != end) {
isBetween++;
if(isBetween)
cout << endl;
for (int i = 0; i < size; ++i)
{
a[i] = 0;
} // init value
int step = 1;
while (cin >> a[step] && a[step] != cookiePos) {
step++;
} //a[step] == cookiepos when after loop
for (int i = 1; i <= step; ++i)
{
cout << "Moving from "<< a[i-1] << " to " << a[i] << ": " << status(a, cookiePos, i) << endl;
}
}
return 0;
}
string status(int* a, int Pos, int i){
int last = abs(a[i-1] - Pos);
int now = abs(a[i] - Pos); // todo cast!!
// string res = "";
if (now == 0 )
{
return "found it!";
}
else if (now == last)
{
return "same.";
}
else if (now > last)
{
return "colder.";
}
else
{
return "warmer.";
}
}
always got a presentation error. Fortunately, referring to other's code, then I know I shoulda give a space between two blocks, neither can be at the beginning nor the end of the whole thing