小小程序,,大大问题!!!
#include <stdafx.h>#include "iostream"
#include <cmath>
#include <stdlib.h>
using namespace std;
void main(){
cout<<"please input a number.\n";
int m;
double n;
cin>>m;
n=sqrt(m*1.0);
for(int i=1;i<=n;++i)
if(m%i==0){
cout<<m<<" isn't a prime.\n ";
}
else cout<<m<<" is a prime.\n";
system("pause");
}
搞不懂。。会出现这样的结果
please input a number.
4
4 isn't a prime.
4 isn't a prime.
输入5时有不一样了
please input a number.
5
5 isn't a prime.
5 is a prime.