Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------------------------------------------------------------------------------------------
- // Exercise 7
- // ----------
- //
- // General : The program will get two numbers and checks if those numbers are a possible result of a basketball game in euroleague.
- //
- // Input : Two numbers.
- //
- // 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.
- //
- // Output : Prints True if those number can be a result of a basketball game in euroleague and False if they cant.
- //
- //------------------------------------------------------------------------------------------------------------------------------
- // Programmer: Ohad Ozcohen
- // Date: 9.9.2016
- //------------------------------------------------------------------------------------------------------------------------------
- #include <stdio.h>
- typedef char bool;
- #define TRUE 1
- #define FALSE 0
- bool main(void)
- {
- int num1, num2;
- int winning_team, losing_team;
- bool realistic_result = TRUE;
- printf("Please enter the first number: ");
- scanf_s("%d", &num1);
- printf("Please enter the second number: ");
- scanf_s("%d", &num2);
- winning_team = ((num1 + num2) + (num1 - num2)) / 2;
- losing_team = num1 + num2 - winning_team;
- if (winning_team > 150 || losing_team < 40 || losing_team == winning_team || winning_team - losing_team>60)
- {
- printf("The numbers cant be a realistic result");
- realistic_result = FALSE;
- return realistic_result;
- }
- else
- {
- printf("The numbers can be a realistic result");
- realistic_result = TRUE;
- return realistic_result;
- }
- }
Add Comment
Please, Sign In to add comment