第十一周上机项目六(3)素数
来源:互联网 发布:json 数据解析 乱码 编辑:程序博客网 时间:2024/06/04 19:02
/* *Copyright (c) 2014, 烟台大学计算机学院 *All rights reserved. *文件名称:test.cpp *作者:陈栋梁 *完成日期:2014年 11 月 7日 *版本号:v1.0 * *问题描述: *输入描述: *输出描述: */#include <iostream>#include <cmath>using namespace std;bool isPrimer(int);int main(){ int m; cout<<"请输入:"; cin>>m; if (isPrimer(m)) cout<<m<<"是素数。"; else cout<<m<<"不是素数"; return 0;}bool isPrimer(int x){ bool prime=true; int k=int(sqrt(x)); int i; for (i=2; i<=k; i++) { if(x%i==0) { prime=false; break; } } return prime;}
运行结果:
0 0
- 第十一周上机项目六(3)素数
- 第十一周上机项目六(4)回文素数
- 第十一周上机项目六(5)可逆素数
- 第十一周项目六(3)素数
- 第十一周项目六:素数(3)
- 第十一周项目六 回文素数(3)素数
- 第十一周上机项目六(1)
- 第十一周项目六-回文-素数3
- 第十一周项目六——回文,素数(3)
- 第十一周项目六——回文,素数(3)
- 第十一周项目六回文,素数(3)
- 第十一周 项目六:素数
- 第十一周项目六:素数
- 第十一周项目六 素数
- 第十一周上机项目六(2)回文数
- 第十一周上机项目一(3)
- 第十一周项目六——回文,素数(4-3)
- 第十一周项目六 回文素数(1)
- 将index.jsp去掉
- HDU 5090 Game with Pearls(贪心)
- http错误码大全
- Mybatis foreach 批量操作
- css效果
- 第十一周上机项目六(3)素数
- Path Sum II(leetcode)
- http://write.blog.csdn.net/postedit/40896053
- Oracle 控制文件(controlfile)
- 从容网掀起互联网金融新革命
- GestureDetector.OnGestureListener 详解
- 使用WinSCP软件在windows和Linux中进行文件传输
- lua实现的A星(a star)算法
- UVA - 10041 Vito's Family 求中位数