找到满足条件的数组

#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <map>
using namespace std;

int main() 

    bool b[1000] = {false};
    int temp = 0;
    for(int i = 1; i < 1000; i++)
    {
        temp += i;
        int j = i;
        while(j != 0)
        {
            temp += (j % 10);
            j = j/10;
        }
        if(temp < 1000)
        {
            b[temp] = true;
        }
    }
    for(int i = 1;i < 1000; i++)
    {
        cout<<i<<": "<<b[i]<<endl;
    }

    system("pause");
    return 0;
}

posted on 2012-08-30 14:13 三少_爷 阅读(175) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2012年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿

随笔分类

随笔档案

My Website

搜索

最新评论

阅读排行榜

评论排行榜