ohad

Untitled

Sep 8th, 2016
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //------------------------------------------------------------------------------------------------------------------------------
  2. //                                                                  Exercise 7
  3. //                                                                  ----------
  4. //
  5. // General : The program will get two numbers and checks if those numbers are a possible result of a basketball game in euroleague.
  6. //
  7. // Input   : Two numbers.
  8. //
  9. // Process : The program checks if the numbers can be a realistic result of a basketball game in euroleague according to the known conditions for realistic results.
  10. //
  11. // Output  : Prints True if those number can be a result of a basketball game in euroleague and False if they cant.
  12. //
  13. //------------------------------------------------------------------------------------------------------------------------------
  14. // Programmer: Ohad Ozcohen
  15. // Date: 9.9.2016
  16. //------------------------------------------------------------------------------------------------------------------------------
  17. #include <stdio.h>
  18. typedef char bool;
  19. #define TRUE 1
  20. #define FALSE 0
  21. bool main(void)
  22. {
  23.     int num1, num2;
  24.     int winning_team, losing_team;
  25.     bool realistic_result = TRUE;
  26.     printf("Please enter the first number: ");
  27.     scanf_s("%d", &num1);
  28.     printf("Please enter the second number: ");
  29.     scanf_s("%d", &num2);
  30.     winning_team = ((num1 + num2) + (num1 - num2)) / 2;
  31.     losing_team = num1 + num2 - winning_team;
  32.     if (winning_team > 150 || losing_team < 40 || losing_team == winning_team || winning_team - losing_team>60)
  33.     {
  34.         printf("The numbers cant be a realistic result");
  35.         realistic_result = FALSE;
  36.         return realistic_result;
  37.     }
  38.     else
  39.     {
  40.         printf("The numbers can be a realistic result");
  41.         realistic_result = TRUE;
  42.         return realistic_result;
  43.  
  44.     }
  45.  
  46. }
Add Comment
Please, Sign In to add comment