标签:hdu2097 hdu 2097 nyoj414 nyoj 414
2992 1234 0
2992 is a Sky Number. 1234 is not a Sky Number.
#include <stdio.h> int main() { int b[3],a[3]={10,16,12};//数组b贮存进制转换后的数,数组a贮存需要转换的进制 int i,sum,p,n; while(scanf("%d",&n)!=EOF&&n!=0) { for(i=0;i<3;i++) { p=n,sum=0; while(p) sum=sum+p%a[i],p=p/a[i]; b[i]=sum; } if(b[1]==b[0]&&b[1]==b[2])//如果转换后的三个进制数相等 printf("%d is a Sky Number.\n",n); else printf("%d is not a Sky Number.\n",n); } return 0; }
标签:hdu2097 hdu 2097 nyoj414 nyoj 414
原文地址:http://blog.csdn.net/su20145104009/article/details/45483793