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
#include<iostream>
#include <string>
usingnamespace 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;
}