Here's a problem we're supposed to do for my class:
Input five numbers from the user and print the highest, the lowest positive number, the highest (closest to zero) negative number and the lowest number. If the user enters all positives or all negatives, print "none" for the missing output.
I'm not sure how to do this. So far, I have:
#include "stub.h"
int main()
{
int x = 0;
int highest_pos = 0;
int lowest_pos;
int counter;
int highest_neg;
int lowest_neg;
for(counter = 1; counter <= 5; counter ++)
{
cin >> x;
if ( x > highest_pos && x > 0)
highest_pos = x;
if ( x < lowest_pos && x > 0)
lowest_pos = x;
if ( x > highest_neg && x < 0)
highest_neg = x;
if ( x < lowest_neg && x < 0)
lowest_neg = x;
}
cout << highest_pos << " " << lowest_pos << " " << endl << highest_neg << " " << lowest_neg << endl;
cin.ignore(INT_MAX);
getchar();
return 0;
}