当前位置:网站首页>习题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;
}
边栏推荐
- 每日一题-1317. 将整数转换为两个无零整数的和
- Tkinter study notes (III)
- Superscalar processor design yaoyongbin Chapter 2 cache -- Excerpt from subsection 2.3
- Unity3d getlaunchintintforpackage getting package returned null
- Three methods of quick sorting
- Huawei equipment configuration h-vpn
- Analysis of the implementation principle of an open source markdown to rich text editor
- 超標量處理器設計 姚永斌 第2章 Cache --2.4 小節摘錄
- Go IO module
- Tkinter学习笔记(四)
猜你喜欢
![[today in history] June 11: the co inventor of Monte Carlo method was born; Google launched Google Earth; Google acquires waze](/img/eb/147d4aac20639d50b204dcf424c9e2.png)
[today in history] June 11: the co inventor of Monte Carlo method was born; Google launched Google Earth; Google acquires waze

5.学城项目 支付宝支付

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

超标量处理器设计 姚永斌 第2章 Cache --2.2 小节摘录

Study notes of mattlotlib and Tkinter (I)

科普 | NFT的类型有哪些(上)

【数据挖掘时间序列分析】餐厅销量预测

R language book learning 03 "in simple terms R language data analysis" - Chapter 10 association rules Chapter 11 random forest

Popular science | what are the types of NFT (Part 1)

Tkinter学习笔记(四)
随机推荐
[Chongqing Guangdong education] college physics of Xiangtan University: mechanical and thermal reference materials
Players must read starfish NFT advanced introduction
R7-1 列表或元组的数字元素求和
Precision twist jitter
Introduction to MySQL transactions
Daily question - Roman numeral to integer
论文阅读《Dense Visual SLAM for RGB-D Cameras》
crontab中定时执行shell脚本
Matplotlib和tkinter学习笔记(一)
Huawei equipment configuration h-vpn
Tkinter学习笔记(二)
【学术相关】申请审核制下,到双一流大学读博的难度有多大?
One question of the day - delete duplicates of the ordered array
BUUCTF(5)
R language book learning 03 "in simple terms R language data analysis" - Chapter 7 linear regression model
高考结束,人生才刚刚开始,10年职场老鸟给的建议
69. square root of X
STM32 development note 113:ads1258 drive design - reading temperature value
Collection of articles and literatures related to R language (continuously updated)
6.项目上线