tarms

benny++C, terms, כלליLeave a Comment

/**************************************
binyamin royttenberg
DESCRIPTION: enter three random numbers, the program display the numbers in order 1>2>3.
*****************************************************/
#include <iostream>
using namespace std;
int main()

{
int num1, num2, num3, smallest, middle, biggest;
cout << "enter 3 numbers: " << endl;
cin >> num1 >> num2 >> num3;

if (num1 >= num2 && num2 >= num3)
{
biggest = num1; middle = num2; smallest = num3;
}
if (num1 >= num3 && num3 >= num2)
{
biggest = num1; middle = num3; smallest = num2;
}
if (num2 >= num3 && num3 >= num1)
{
biggest = num2; middle = num3; smallest = num1;
}
if (num2 >= num1 && num1 >= num3)
{
biggest = num2; middle = num1; smallest = num3;
}
if (num3 >= num2 && num2 >= num1)
{
biggest = num3; middle = num2; smallest = num1;
}
if (num3 >= num1 && num1 >= num2)
{
biggest = num3; middle = num1; smallest = num2;
}

cout << smallest << " " << middle << " " << biggest << endl;

return 0;
}
/*************OUTPUT*****************
enter 3 numbers:
54 68 47
47 54 68
Press any key to continue . . .

*****************************************/

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *