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;
}
相关推荐
Larry_Yanan7 小时前
Qt多进程(三)QLocalSocket
开发语言·c++·qt·ui
醒过来摸鱼7 小时前
Java classloader
java·开发语言·python
superman超哥7 小时前
仓颉语言中元组的使用:深度剖析与工程实践
c语言·开发语言·c++·python·仓颉
小鸡吃米…7 小时前
Python - 继承
开发语言·python
JIngJaneIL8 小时前
基于java+ vue农产投入线上管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
祁思妙想8 小时前
Python中的FastAPI框架的设计特点和性能优势
开发语言·python·fastapi
LYFlied8 小时前
【每日算法】LeetCode 153. 寻找旋转排序数组中的最小值
数据结构·算法·leetcode·面试·职场和发展
唐装鼠8 小时前
rust自动调用Deref(deepseek)
开发语言·算法·rust
Lucas555555558 小时前
现代C++四十不惑:AI时代系统软件的基石与新征程
开发语言·c++·人工智能
源代码•宸8 小时前
goframe框架签到系统项目(BITFIELD 命令详解、Redis Key 设计、goframe 框架教程、安装MySQL)
开发语言·数据库·经验分享·redis·后端·mysql·golang