第三周项目4-穷举法-辩数字

问题及代码:

/*
 *Copyright (c) 2016,烟台大学计算机学院
 *All rights reserved.
 *文件名称:zwj.cpp
 *作    者:张伟晶
 *完成日期:2016年3月17日
 *版 本 号:v1.0
 *
 *问题描述:辩数字
 *输入描述:无
 *程序输出:可能的情况
 */
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,e,sum,he;
    for(a=0;a<10;a++)
        for(b=0;b<10;b++)
            for(c=0;c<10;c++)
                for(d=0;d<10;d++)
                    for(e=0;e<10;e++)
                    {
                        sum=a*(b*10+3+c);
                        he=8000+d*100+e*10+9;
                        if(sum*sum==he)
                        {
                            cout<<"["<<a<<"*("<<b*10+3<<")]的平方="<<he;
                            cout<<"\n";
                        }


                    }
}


 

运行结果:

知识点总结:

    穷举法。

学习心得:

    持续努力,保持激情。

你可能感兴趣的:(第三周项目4-穷举法-辩数字)