I'm working on a program called "Squirrelly in the Morning...".
Overall, it's simple, but I cannot get one part of the output right.
The input is a series of integers (i.e. 5, 10, 11, 3, 4, 5...).
The program is looking to see if you are getting "warmer",
"colder", or the "same" when comparing the first digit to the rest of the digits. The output should begin from 0 like this (using the digits above:
Moving from 0 to 10: Same.
Moving from 10 to 11: Colder
Moving from 11 to 3: Warmer
etc..
My problem is, I can't get the out put to start from 0.
Here is my code.
int x,y,p,t;
cin>>x;
y=x;
while (x != 5280)
{
x = 0;
cin>>x;
p = abs(y-x);
if (p == 0)
cout<<"Moving from "<<t<<" to "<<x<<": Found it!"<<endl;
else if (y > p)
cout<<"Moving from "<<t<<" to "<<x<<": Warmer"<<endl;
else if (y < p)
cout<<"Moving from "<<t<<" to "<<x<<": Colder"<<endl;
else if(y == p)
cout<<"Moving from "<<t<<" to "<<x<<": Same"<<endl;
t = x;
}
return 0;
}