博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
算式计算
阅读量:3983 次
发布时间:2019-05-24

本文共 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/

你可能感兴趣的文章
postman调试webservice接口
查看>>
retrofit调试webservice(注意只是调试,没对结果进行处理)
查看>>
flutter-解析json
查看>>
android中shader的使用
查看>>
java LinkedList与ArrayList迭代器遍历和for遍历对比
查看>>
Android DataBinding使用1-普通页面
查看>>
Android DataBinding使用2-Recycleview
查看>>
Dart数据类型
查看>>
drat中构造方法
查看>>
JavaScript的一些基础-数据类型
查看>>
JavaScript基础知识(2)
查看>>
重温activity生命周期
查看>>
转载一个webview开车指南以及实际项目中的使用
查看>>
关于activity保存页面状态的两个方法
查看>>
android中对于非属性动画的整理
查看>>
一个简单的TabLayout的使用
查看>>
关于let{a}=B出现的解构赋值
查看>>
ReactNative使用Redux例子
查看>>
Promise的基本使用
查看>>
android给文字加边框(修改不能居中的问题)
查看>>