本文共 1212 字,大约阅读时间需要 4 分钟。
给定等式 A B C D E 其中每个字母代表一个数字,且不同数字对应不
D F G 同字母。编程求出这些数字并且打出这个数字的 + D F G 算术计算竖式。 ─────── X Y Z D E#include <iostream>
using namespace std; int _tmain(int argc, _TCHAR* argv[]){ int a,b,c,d,e,f,g,x,y,z; for (a = 0; a != 10; ++a){ for (b = 0; b != 10; ++b){ if (a != b){ for (c = 0; c != 10; ++c){ if (c != a && c != b){ for (d = 0; d != 10; ++d){ if (d != c && d != b && d != a){ for (e = 0; e != 10; ++e){ if (e != d && e != c && e != b && e != a){ for (f = 0; f != 10; f += 5){ if (f != e && f != d && f != c && f != b && f != a){ for (g = 0; g != 10; g += 5){ if (g != f && g != e && g != d && g != c && g != b && g != a){ for (x = 0; x != 10; ++x){ if (x != g && x != f && x != e && x != d && x != c && x != b && x != a){ for (y = 0; y != 10; ++y){ if (y != x && y != g && y != f && y != e && y != d && y != c && y != b && y != a){ z = 45 - (a + b + c + d + e + f + g + x + y); int x1 = e + d * 10 + c * 100 + b * 1000 + a * 10000; int x2 = g + f * 10 + d * 100; int x3 = e + d * 10 + z * 100 + y * 1000 + x * 10000; if (x1 + x2 + x2 == x3) { cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << ' ' << g << ' ' << x << ' ' << y << ' ' << z << endl; } } } } } } } } } } } } } } } } } }}
转载地址:http://glpui.baihongyu.com/