Chinaunix首页 | 论坛 | 博客
  • 博客访问: 816776
  • 博文数量: 756
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 4980
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 14:40
文章分类

全部博文(756)

文章存档

2011年(1)

2008年(755)

我的朋友

分类:

2008-10-13 16:14:43

/************************************************************************/
/*  use number 0~9 fill expresstion ____ X_ = ____                     */
/*  author : smileonce                                                  */
/************************************************************************/
// 我来示范一下效率、正确性和易维护性的结合。
// 谁在丢砖头?我不是玻璃干吗砸我,我跑~~~

#include "stdafx.h"
#include 
#include 
using namespace std;

int main(int argc, char** argv)
{
    set<int> num_set;
    for (int i=2; i<=9; i++)
   {
      int max_try = 9876 / i ;     
      for (int j=1234; j<max_try; j++)
      {

            int k = i*j;                   
            
            num_set.clear();

            num_set.insert(0);
            num_set.insert(i);
            
            num_set.insert(j/1000);
            num_set.insert(j/100%10);
            num_set.insert(j/10%10);
            num_set.insert(j%10);
            
            num_set.insert(k/1000);
            num_set.insert(k/100%10);
            num_set.insert(k/10%10);
            num_set.insert(k%10);
            
            if (num_set.size()==10) 
              cout << j << " * " << i << " = " << k << endl;
      }
   }
    return 0;
}

--------------------next---------------------

阅读(795) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~