标签:style blog io color os sp div on log
2992
1234
0
2992 is a Sky Number.
1234 is not a Sky Number.
1 #include <stdio.h> 2 3 int sum(int number,int p); 4 5 int main(){ 6 int n; 7 int sum_10; 8 int sum_12; 9 int sum_16; 10 11 while(1){ 12 scanf("%d",&n); 13 14 if(n==0) 15 break; 16 17 sum_10=sum(n,10); 18 sum_12=sum(n,12); 19 sum_16=sum(n,16); 20 21 if(sum_10==sum_12 && sum_10==sum_16) 22 printf("%d is a Sky Number.\n",n); 23 24 else 25 printf("%d is not a Sky Number.\n",n); 26 } 27 return 0; 28 } 29 30 int sum(int number,int p){ 31 int result; 32 33 result=0; 34 while(number){ 35 result+=number%p; 36 number/=p; 37 } 38 39 return result; 40 }
标签:style blog io color os sp div on log
原文地址:http://www.cnblogs.com/zqxLonely/p/4100212.html