标签: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]); }
标签:class bsp code color self sel cat book div
原文地址:http://www.cnblogs.com/lvcoding/p/6628656.html