首页 > 其他 > 详细

判断满足条件的三位数

时间:2020-01-25 20:29:16      阅读:233      评论:0      收藏:0      [点我收藏+]

https://pintia.cn/problem-sets/12/problems/351

 1 int search(int n)
 2 {
 3     int count = 0;
 4     int num_sqrt; //平方根的整数部分
 5     int single, ten, hundred;
 6     for (int i = 101; i <= n; i++)
 7     {
 8         num_sqrt = (int)sqrt(i);
 9         if (i == num_sqrt * num_sqrt)
10         {
11             single = i % 10;
12             ten = i % 100 / 10;
13             hundred = i / 100;
14             if (single == ten || single == hundred || ten == hundred)
15             {
16                 count++;
17             }
18         }
19     }
20 
21     return count;
22 }

 

判断满足条件的三位数

原文:https://www.cnblogs.com/2018jason/p/12233341.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!