本题要求实现一个函数,判断任一给定整数N是否满足条件:它是完全平方数,又至少有两位数字相同,如144、676等。 **函数接口定义:** ```c int IsTheNumber ( const int N ); ``` 其中N是用户传入的参数。如果N满足条件,则该函数必须返回1,否则返回0。 **裁判测试程序样例:** ```c #include #include 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; } /* 你的代码将被嵌在这里 */ ``` 输入样例: ```c 105 500 ``` 输出样例: ```c cnt = 6 ``` **答案** ```c int IsTheNumber ( const int N ){ int a,temp[1000],count=0,i,m=N; if(N<=0){ return 0; } a=(int)sqrt(N); if (a*a==N){ while(m>0){ temp[count]=m%10; //取个位数字 m=m/10;//去掉个位数字 for(i=0;i Last modification:March 18th, 2020 at 10:04 am © The copyright belongs to the author Support If you think my article is useful to you, please feel free to appreciate ×Close Appreciate the author 谢谢,不用了 Pay by AliPay Pay by WeChat