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

全部博文(756)

文章存档

2011年(1)

2008年(755)

我的朋友

分类:

2008-10-13 16:14:41

下一个数字是什么?32 35 40 44 52 112 ____

据说是一道小学题,洋文出的。当然这么刁钻的题目只有周星星大哥才猜得出来,嘿嘿。看了答案就明白怎么回事了,嘿嘿。

答案如下:

//author: *.*.zhou
#include 
#include 
using namespace std;

int main( void )
{
    const unsigned int n=32u;
    for( size_t base=10u; base>1u; --base )
    {
        string os;
        for( unsigned int m=n; m>0u; m/=base )
        {
            os.insert( os.begin(), (char)(m%base)+'0' );
        }
        cout << os << endl;
    }

    return 0;
}

运行结果:

32
35
40
44
52
112
200
1012
100000

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

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