码迷,mamicode.com
首页 > 其他好文 > 详细

Generator

时间:2017-03-27 21:24:49      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:class   bsp   code   color   self   sel   cat   book   div   

#include<stdio.h>
int book[10001];
int add[4];
int one[10001];
int two[10001];
void fun(int x){
    int temp=x;
    int y=x;
    int t=0;
    while(x){
        add[t]=x%10;
        t++;
        x=x/10;
    }
    for(int j=0;j<t;j++)
        temp=temp+add[j];
    if(book[temp]==0) {
        one[temp]=y;
        book[temp]++;
    }
    else if(book[temp]==1){
        two[temp]=y;
        book[temp]++;
    }

}
int main(){
    int self=0;
    int dup=0;
    for(int i=1;i<=5000;i++) fun(i);
    printf("Print self numbers\n");
    for(int i=1;i<=5000;i++)
        if(book[i]==0){ 
            printf("%d ",i);
            self=self+i;
        }
        else if(book[i]==2)
            dup++;
    printf("\n");
    printf("Sum of self numbers : %d\n\n",self);
    printf("duplicate generator numbers\n\n");
    printf("Total duplicate numbers : %d\n\n",dup);
    for(int i=0;i<=200;i++)
        if(book[i]==2)
            printf("%d : %d       %d\n",i,one[i],two[i]);
}

 

Generator

标签:class   bsp   code   color   self   sel   cat   book   div   

原文地址:http://www.cnblogs.com/lvcoding/p/6628656.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!