首页 > 后端开发 > C++ > 正文

打印C语言中的非平方数

WBOY
发布: 2023-08-26 23:09:04
转载
1422人浏览过

程序描述

一个数的平方是该数乘以自身。

一个平方数或完全平方是一个整数,它是一个整数的平方;

完全平方数是整数的平方。

1, 4, 9, 16, 25, 36, 49, 64, 81, 100
登录后复制

这里是从1到100的所有完全平方数的平方根。

&radic;1 = 1 since 1<sup>2 </sup>= 1
&radic;4 = 2 since 2<sup>2 </sup>= 4
&radic;9 = 3 since 3<sup>2 </sup>= 9
&radic;16 = 4 since 4<sup>2 </sup>= 16
&radic;25 = 5 since 5<sup>2 </sup>= 25
&radic;36 = 6 since 6<sup>2 </sup>= 36
&radic;49 = 7 since 7<sup>2 </sup>= 49
&radic;64 = 8 since 8<sup>2 </sup>= 64
&radic;81 = 9 since 9<sup>2 </sup>= 81
&radic;100 = 10 since 10<sup>2 </sup>= 100
登录后复制

A non-perfect square is every number that is not the result of squaring an integer with itself.

立即学习C语言免费学习笔记(深入)”;

The below numbers are non-perfect square numbers

2,3,5,6,7,8,10,11,12,13,14,15,17,18,19,20,21,22,23,24,26 etc&hellip;
登录后复制

算法

Check all numbers from 1 to the user specified number.
Check if it is perfect square or not.
If not a perfect square, print the Non Perfect Square Number.
登录后复制

Example

的中文翻译为:

示例

/* Program to print non square numbers */
#include <stdio.h>
#include <math.h>
int main() {
   int number,i,x;
   int times = 0;
   clrscr();
   printf("Print the Non Square Numbers till:");
   scanf("%d", &number);
   printf("The Non Squre Numbers are:");
   printf("</p><p>");
   for(i = 1;times<number;i++,times++){
      x = sqrt(i);
      if(i!=x*x){
         printf("%d\t", i);
      }
   }
   getch();
   return 0;
}
登录后复制

输出

打印C语言中的非平方数

以上就是打印C语言中的非平方数的详细内容,更多请关注php中文网其它相关文章!

全能打印神器
全能打印神器

全能打印神器是一款非常好用的打印软件,可以在电脑、手机、平板电脑等设备上使用。支持无线打印和云打印,操作非常简单,使用起来也非常方便,有需要的小伙伴快来保存下载体验吧!

下载
相关标签:
来源:tutorialspoint网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号