新同学的年龄

来源:互联网 发布:元胞自动机 python 编辑:程序博客网 时间:2024/04/28 01:49
/*
 * 52.cpp
 *
 *  Created on: 2011-8-9
 *      Author: san
 */


# include <stdio.h>


int main(void)
{
long a[10] = {
0
};
long s[10] = {
0
};
int i;
long n3;
long n4;
int x = 18;


do
{
n3 = x*x*x;
for (i=3; i>=0; i--)
{
a[i] = n3 % 10;
n3 /= 10;
}
n4 = x*x*x*x;
for (i=9; i>=4; i--)
{
a[i] = n4 % 10;
n4 /= 10;
}


for (i=0; i<=9; i++)
s[a[i]]++;
for (i=0; i<=9; i++)
if(s[i]==1) /*判断有无重复数字*/
   {
     if(i==9)
     printf("\n the number is %d\n",x);/*将结果输出*/
   }
     else break;/*跳出for循环*/
   x++;
} while (x<22);


return 0;
}
原创粉丝点击