#include <stdio.h>
#include <math.h>
int IsTheNumber(const int N);
int main()
{
int n1, n2, i, cnt;
scanf("%d %d", &n1, &n2);
cnt = 0;
for (i = n1; i <= n2; i++)
{
if (IsTheNumber(i))
cnt++;
}
printf("cnt = %d\n", cnt);
return 0;
}
int IsTheNumber(const int N)
{
int p = N;
int num[10] = {0};
int n = sqrt(N);
if (n * n == N)
{
while (p != 0)
{
num[p % 10]++; //奇妙小统计
p = p / 10;
}
for (int i = 0; i < 10; i++)
{
if (num[i] >= 2) //只要碰到有重复的,所属位置必定大于等于2
{
return 1;
}
}
return 0;
}
else
{
return 0;
}
}
基础编程题目集 6-7 统计某类完全平方数 (20分)
猜你喜欢
转载自blog.csdn.net/qq_44458489/article/details/105522759
今日推荐
周排行