Chinaunix首页 | 论坛 | 博客
  • 博客访问: 98169
  • 博文数量: 29
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 476
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-07 15:10
文章分类

全部博文(29)

文章存档

2011年(1)

2008年(28)

我的朋友

分类: C/C++

2008-08-19 17:48:49

/********************************************
*      VINGT
*       CINQ 
*    +  CINQ
*  ------------- 
*     TRENTE
*(1)不同的英文字母代表不同的数字
*(2)每个数最左边一个数字不能为0,即V,C,T不能等于0
********************************************/
-----------------------------------------------------------------------
 

#include <stdio.h>

int main()
{
    int V,I,N,G,T,C,Q,E,R;
    T = 1; R = 0;
    for(V=8; V<10; V++)
    {
        for(I=1; I<10; I++)
        {
            if(I!=T && I!=V)
            {
                for(N=1; N<10; N++)
                {
                    if(N!=T && N!=V && N!=I)
                    {
                        for(C=1; C<10; C++)
                        {
                            if(C!=T && C!=V && C!=I && C!=N)
                            {
                                for(G=1; G<10; G++)
                                {
                                    if(G!=T && G!=V && G!=I && G!=N && G!=C)
                                    {
                                        for(Q=1; Q<10; Q++)
                                        {
                                            if(Q!=T && Q!=V && Q!=I && Q!=N && Q!=C && Q!=G)
                                            {
                                                for(E=1; E<10; E++)
                                                {
                                                    if(E!=T && E!=V && E!=I && E!=N && E!=C && E!=G && E!=Q)
                                                    {
                                                        if(((T+G*10+N*100+I*1000+V*10000)+2*(Q+N*10+I*100+C*1000))==(E+T*10+N*100+E*1000+R*10000+T*100000))
                                                        {
                                                            printf("R:%d\nT:%d\nV:%d\nI:%d\nN:%d\nC:%d\nG:%d\nQ:%d\nE:%d\n",R,T,V,I,N,C,G,Q,E);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}

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