当前位置:网站首页>习题10-1 判断满足条件的三位数 (15 分)
习题10-1 判断满足条件的三位数 (15 分)
2022-06-11 22:18:00 【小言同学Y】
本题要求实现一个函数,统计给定区间内的三位数中有两位数字相同的完全平方数(如144、676)的个数。
函数接口定义:
int search( int n );
其中传入的参数int n是一个三位数的正整数(最高位数字非0)。函数search返回[101, n]区间内所有满足条件的数的个数。
裁判测试程序样例:
#include <stdio.h>
#include <math.h>int search( int n );
int main()
{
int number;scanf("%d",&number);
printf("count=%d\n",search(number));return 0;
}
/* 你的代码将被嵌在这里 */
输入样例:
500
输出样例:
count=6
int search( int n ){
int i,num;
int sum=0;
int a,b,c;
for(i=101;i<n;i++){
a=i/100;
b=(i/10)%10;
c=i%10;
num=sqrt(i);
if(num*num==i&&(a==b||b==c||c==a)){
sum++;
}
}
return sum;
}
边栏推荐
- Submit task to thread pool
- Daily question - Roman numeral to integer
- Top - K problem
- Glory earbud 3 Pro with three global first strong breakdowns flagship earphone Market
- How to adjust the font blur of win10
- STM32 development note 113:ads1258 drive design - reading temperature value
- Leetcode stack topic summary
- Stack栈的实现
- Tkinter study notes (IV)
- Collection of articles and literatures related to R language (continuously updated)
猜你喜欢

Superscalar processor design yaoyongbin Chapter 2 cache -- Excerpt from subsection 2.4

leetcode 257. Binary tree paths all paths to a binary tree (simple)

Tkinter study notes (II)

Tkinter学习笔记(四)

A simple example of linear regression in machine learning
![[academic related] under the application review system, how difficult is it to study for a doctoral degree in a double first-class university?](/img/cd/e7ffecbee13596f2298ee8c0a5b873.jpg)
[academic related] under the application review system, how difficult is it to study for a doctoral degree in a double first-class university?

电脑强制关机 oracle登录不上

Implementation stack and queue

Internet of things development practice 18 scenario linkage: how does an intelligent light perceive light? (I) (learning notes)

Take off efficiently! Can it be developed like this?
随机推荐
带有 ceph-csi 的静态 PVC
SequenceList顺序表的实现
Basic operation and question type summary of linked list
机器学习之Logistic回归简单实例
360 online enterprise security cloud is open to small, medium and micro enterprises for free
Unity3D getLaunchIntentForPackage 获取包返回null问题
[Yu Yue education] Yancheng Normal University Advanced Algebra reference
69. square root of X
Internet of things development practice 18 scenario linkage: how does an intelligent light perceive light? (I) (learning notes)
Go encoding package
Analysis of the implementation principle of an open source markdown to rich text editor
Nmap performs analysis of all network segment IP survivals in host detection
The shortcomings of the "big model" and the strengths of the "knowledge map"
Go IO module
如果重来一次高考,我要好好学数学!
R7-1 列表或元组的数字元素求和
打印机无法打印测试页是什么原因
Two methods to judge the storage of large and small end
Latex combat notes 3- macro package and control commands
If I take the college entrance examination again, I will study mathematics well!