Hello everyone
I am thinking of writing a function and wanted your opinion on the best solution to solve my problem
I have the number 9 which is the answer to the question and all possible questions that would equal that answer
However discovering the question is where I am finding it difficult.
I would like to implement a way to take the number 9 and print all possible methods of addition (+) of two numbers no higher than 9 themselves which the resultant would equal 9. As an example:
0 + 9
1 + 8
2 + 7
---------
9 + 0
8 + 1
7 + 2
Any ideas.
*cheers
Maboroshi
Finding all possible equasions
Type in number, and it will output all the addition possibilities (without using negative numbers). It can also go as high as you want for the number.
Code: Select all
#include <iostream>
void func(int a){
for(int i=0;i<a;i++)
std::cout<<'\n'<<i<<'+'<<a<<'='<<i+a--;
}
int main(){
int number;
std::cin>>number;
func(number);
return 0;
}