杭电OJ2097

在这里插入图片描述

#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	while(cin>>n)
	{
		if(n==0)
		break;
		int t=n;
		int c1=0,c2=0,c3=0;
		//计算十进制数的各位和 
	    c1=t/1000+t/100%10+t/10%10+t%10;
		t=n;
		while(t>0){
	   	   c2+=t%12;
	   	    t=t/12; 
	   }
	   t=n;
	   while(t>0){
	   	    c3+=t%16;
	   	    t=t/16; 
	   }
	   if(c1==c2&&c1==c3)
	      cout<<n<<" is a Sky Number."<<endl;
		else
		  cout<<n<<" is not a Sky Number."<<endl;	 
	}
	return 0;
}
发布了43 篇原创文章 · 获赞 0 · 访问量 578

猜你喜欢

转载自blog.csdn.net/weixin_45191675/article/details/104950699