您的位置:首页 > 其它

hdu 2097 Sky数

2012-08-09 17:43 197 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2097

进制转换类型的题

#include <iostream>
using namespace std;
int test(int n,int hex){
	int sum=0;
	while(n){
		sum+=n%hex;
		n=n/hex;
	}
	return sum;
}
int main()
{
	int n;
	while(cin>>n&&n){
		if((test(n,10)==test(n,16))&&(test(n,12)==test(n,16)))
		cout<<n<<" is a Sky Number."<<endl;
		else cout<<n<<" is not a Sky Number."<<endl;
	}
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: