tong.cpp

来自「examples C,c++ codes programs」· C++ 代码 · 共 30 行

CPP
30
字号
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<math.h>
int ktsnt( int n)
{
int i;
for(i=2;i<(sqrt(n)+1);i++)
if(n%i==0) return 0;
return 1;
}
void main()
{
int n;
cout<<"kiem tra so nguyen to"<<endl;
do
{
cout<<"\nnhap n = ";
cin>>n;
}
while (n<2||n>100);


if (ktsnt(n)==0)
cout<<n <<" khong la so nguyen to";
else cout<<n <<" la so nguyen to";
getch();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?