计算出进制和即可。
#include<iostream> using namespace std; int GetSum(int x,int n) { int sum=0; while(x) { sum+=x%n; x/=n; } return sum; } int main() { int n; while(cin>>n &&n) { if(GetSum(n,10)==GetSum(n,16) &&GetSum(n,12)==GetSum(n,16)) cout<<n<<" is a Sky Number."<<endl; else cout<<n<<" is not a Sky Number."<<endl; } return 0; }
时间: 2024-10-10 21:23:35