Hey i need some help

So i want to make a program that takes 2 3-digit-numbers, A and B, and when I add those numbers the result is C, which is a 3-digit-number, but the catch is that this numbers must be made up from 1-9 and they can me repeated, and the individual digits on C must add up to 18.

i have made a simple code that gets me the results for C but i can't think of a way to get A and B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 #include<iostream>
#include <string>
using namespace std;

int main()
{
	int a, b, c, d, e, f, g, h, i, j;
	/*134 <= a & b <= 746*/
	for (i= 0 ; i <= 999 ; i++)
	{
		c = i;
		//j = c;
		d = c / 100;//pour les chiffre centaine 
		e = (c - (d * 100)) / 10;//pour les dizaine
		f = (c - (d * 100) - (e * 10));////por les unites
		h = d + e + f;
		if ((h == 18) && (e != f) && (f != d) && (d != e)) 
		{
			cout << h << "=" << d << "+" << e << "+" << f << endl;
			b = c - a;
			cout << c<< endl;
		}
			
	}
	return 0;
}
11
You could randomly generate a and b or you could get them from user input.
use rand():
int r = rand();
Topic archived. No new replies allowed.