Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26836
  • 博文数量: 38
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 390
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-29 22:54
文章分类

全部博文(38)

文章存档

2010年(38)

我的朋友
最近访客

分类: C/C++

2010-05-29 23:14:52

      ABC
*     CAB
-------------
AXCAXC
就是这样一个乘法题目,算来不难,因此得到3等奖

/*
* NOC2005
* Program: David Zhang (2006-Jun-9)
* E_mail: crispgm@gmail.com
*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>


void main()
{
    long int a,b,c,x,y,z;
    long int t,p,q,total;
    char s[20];

    for(a=1;a<=9;a++){

        for(b=1;b<=9;b++){
            for(c=0;c<=9;c++){
                if(a!=b && b!=c){
                p=a*100+b*10+c;
                q=b*100+a*10+c;
                total=p*q;
                if(total>=100000 && total<=999999){
                    t=p*c;
                    ltoa(t,s,10);
                    if(strlen(s)==4){
                        t=p*a;
                        ltoa(t,s,10);
                        x=t%100;
                        y=x%10;
                        if(y==a && strlen(s)==3){
                            t=p*b;
                            ltoa(t,s,10);
                            x=t%1000;
                            y=x%100;
                            z=y%10;
                            if(z==b && strlen(s)==4)
                            printf(" %d\n* %d\n------\n%d\n",p,q,total);
                       }
                   }
               }
           }
       }
   }

}


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