ch4_7.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:0k
源码类别:
C#编程
开发平台:
Visual C++
- //*********************
- //** ch4_7.cpp **
- //*********************
- #include <iostream.h>
- #include <math.h>
- void main()
- {
- //输入
- long m;
- cout <<"please input a number:n";
- cin >>m;
- //处理
- double sqrtm=sqrt(m); //用到math.h
- int i;
- for(i=2; i<=sqrtm; i++)
- if(m%i==0)
- break;
- //输出
- if(sqrtm<i)
- cout <<m <<" is prime.n";
- else
- cout <<m <<" isn't prime.n";
- }