辩数字

/*
*Copyright(c) 2016.烟台大学计算机与控制工程学院
*ALL rights  reserved.
*文件名称:main.cpp
*作者:赵子琳
*完成日期:2016年6月21日
*问题描述:有等式[※×(※3+※)] =8※※9,其中※处为 1个数字,滴上了墨水无法辨认。请编程找出※表
2
示哪个数字。
拓展:有等式[※×(※3○※)]  =8※※9,其中※处为 1个数字,○处为+、-、×、÷四个运算
2
符之一,现滴上了墨水无法辨认。请编程找出※表示哪个数字,○表示哪个运算符。
*/
#include <iostream>
#include <cmath>
using namespace std;
 int main()
{
 int a,b,c,d,e,y,z,w;
 for (a=1;a<10;a++)
    for (b=1;b<10;b++)
    for (c=1;c<10;c++)
    for (d=0;d<10;d++)
    for (e=0;e<10;e++)
 {
     w=a*(b*10+3+c);
     y=w*w;
     z=8000+100*d+10*e+9;
  if(y==z)
  cout << a<<'\t'<<b<<'\t'<<c<<'\t'<<d<<'\t'<<e<<endl;
 }
 return 0;
}

发布了129 篇原创文章 · 获赞 14 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_33757765/article/details/51727819