杭电2097

#include "stdio.h"

int fun(int index , int k);
int main(int argc, char* argv[])
{
	int index;
	int k10,k16,k12;
	while (scanf("%d",&index) ==1 && index != 0)
	{
		k10 = fun(index , 10 );
		k16 = fun(index , 16);
		k12 = fun(index , 12);
		if (k10 == k16 && k16 == k12)
		{
			printf("%d is a Sky Number.\n",index);
		}
		else
			printf("%d is not a Sky Number.\n",index);
	}
	return 0;
}

int fun(int index , int k)
{
	int sum;
	sum = 0 ;
	while (index)
	{
		sum += index % k ;
		index = index / k ;
	}
	return sum ;
}


 

你可能感兴趣的:(include,fun)