标签:
#include<iostream> using namespace std; bool selfNum[10000]; bool findNoneSelfNum(int index){ int one,ten,hundred,thousand; if(index>=10000){ return false; } if(selfNum[index]==false){ return true; } thousand=index/1000; hundred=(index-thousand*1000)/100; ten=(index-thousand*1000-hundred*100)/10; one=index-thousand*1000-hundred*100-ten*10; int noneSelfNum=index+thousand+hundred+ten+one; if(noneSelfNum<10000){ findNoneSelfNum(noneSelfNum); selfNum[noneSelfNum]=false; }else{ return false; } } int main(int argc, char *argv[]){ for(int i=1;i<10000;i++){ selfNum[i]=true; } for(int i=1;i<10000;i++){ findNoneSelfNum(i); } for(int i=1;i<10000;i++){ if(selfNum[i]){ cout<<i<<endl; } } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/eddy_liu/article/details/47208093