找到满足条件的数组

#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 三少_爷 阅读(187) 评论(0)  编辑 收藏 引用

<2025年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

导航

统计

常用链接

留言簿

随笔分类

随笔档案

My Website

搜索

最新评论

阅读排行榜

评论排行榜