EP 241 Computer Programming
 


EP241 - Homework


Football Score

Consider the final score of a football match is m-n where m and n are non-negative integers.
Write a C++ program to read m and n from keyboard and list all possible combinations to get the score m-n.

Example outputs:

input m : 1
input n : 0
Possible combinations:
0-0, 1-0

input m : 4
input n : 0
Possible combinations:
0-0, 1-0, 2-0, 3-0, 4-0

input m : 1
input n : 1
Possible combinations:
0-0, 1-0, 1-1
0-0, 0-1, 1-1

input m : 2
input n : 1
Possible combinations:
0-0, 1-0, 2-0, 2-1
0-0, 1-0, 1-1, 2-1
0-0, 0-1, 1-1, 2-1

input m : 2
input n : 2
Possible combinations:
0-0, 1-0, 1-1, 2-1, 2-2
0-0, 1-0, 1-1, 1-2, 2-2
0-0, 1-0, 2-0, 2-1, 2-2
0-0, 0-1, 1-1, 1-2, 2-2
0-0, 0-1, 1-1, 2-1, 2-2
0-0, 0-1, 0-2, 1-2, 2-2

input m : 3
input n : 2
Possible combinations:
0-0, 0-1, 0-2, 1-2, 2-2, 3-2
0-0, 0-1, 1-1, 1-2, 2-2, 3-2
0-0, 1-0, 1-1, 1-2, 2-2, 3-2
0-0, 0-1, 1-1, 2-1, 2-2, 3-2
0-0, 1-0, 1-1, 2-1, 2-2, 3-2
0-0, 1-0, 2-0, 2-1, 2-2, 3-2
0-0, 0-1, 1-1, 2-1, 3-1, 3-2
0-0, 1-0, 1-1, 2-1, 3-1, 3-2
0-0, 1-0, 2-0, 2-1, 3-1, 3-2
0-0, 1-0, 2-0, 3-0, 3-1, 3-2

University of Gaziantep - Department of Engineering Physics (2005 - 2024)