C语言——使用for循环找出100~200之间的完全平方数

方法一

cpp 复制代码
#include <stdio.h>
#include <math.h>

int main() {
    int i;
    for (i = 100; i <= 200; i++) 
    {
        int squareRoot = sqrt(i);
        if (squareRoot * squareRoot == i) 
        {
            printf("%d ", i);
        }
    }
    return 0;
}

方法二

cpp 复制代码
#include <stdio.h>

int main() {
    int i;
    for (i = 10; i <= 14; i++)   //因为14的平方是196,小于200
    {
        printf("%d ", i * i);
    }
    return 0;
}

方法三

cpp 复制代码
#include <stdio.h>

int main() {
    int i, square;

    for (i = 1; i <= 14; ++i)  //因为14的平方是196,小于200
    {
        square = i * i;
        
        if (square >= 100 && square <= 200) 
        {
            printf("%d\n", square);
        }
    }

    return 0;
}
相关推荐
leaves falling4 小时前
C++模板进阶
开发语言·c++
无敌昊哥战神5 小时前
【保姆级题解】力扣17. 电话号码的字母组合 (回溯算法经典入门) | Python/C/C++多语言详解
c语言·c++·python·算法·leetcode
脱氧核糖核酸__5 小时前
LeetCode热题100——238.除了自身以外数组的乘积(题目+题解+答案)
数据结构·c++·算法·leetcode
再卷也是菜5 小时前
算法提高篇(1)线段树(上)
数据结构·算法
py有趣5 小时前
力扣热门100题之单词拆分
算法·leetcode
坐吃山猪5 小时前
Python27_协程游戏理解
开发语言·python·游戏
gCode Teacher 格码致知5 小时前
Javascript提高:小数精度和随机数-由Deepseek产生
开发语言·javascript·ecmascript
椰猫子5 小时前
Javaweb(Filter、Listener、AJAX、JSON)
java·开发语言
j_xxx404_6 小时前
C++算法:哈希表(简介|两数之和|判断是否互为字符重排)
数据结构·c++·算法·leetcode·蓝桥杯·力扣·散列表
盛世宏博北京6 小时前
以太网温湿度传感器运维技巧,提升设备稳定性与使用寿命
开发语言·php·以太网温湿度传感器