#include <iostream>
using namespace std;
int main ()
{
cout << "starting program" << endl;
for (int a=1; a<10; a++)
{
for (int b=1; b<10; b++)
{
for (int c=1; c<10; c++)
{
for (int d=1; d<10; d++)
{
for (int e=1; e<10; e++)
{
for (int f=1; f<10; f++)
{
for (int g=1; g<10; g++)
{
for (int h=1; h<10; h++)
{
for (int i=1; i<10; i++)
if (a+(13 * b / c) +d +(12 * e )- f - 11 + (g * h / i) - 10 == 66)
{
cout << a << b << c << d << e << f << g << h << i << endl ;
}
}
}
}
}
}
}
}
}
return 0;
}
so i have this code that finds every possible combination between 1 and 9 to see which one will solve the equation and as you can see i have 9 variables and this equation can be solved in many many different combinations however what im aiming for is to have the variables not equal to one another of course i could approach by writing each one of the conditions in the if statement conditions but that would be 81 conditions to put and thats alot and stupid so is there any way to approach this in a smart way btw im a beginner so if you have any advanced methods to offer please explain it briefly thanks in advance :)
Aucun commentaire:
Enregistrer un commentaire