Технология программирования
C++
Главная »
2019 » Ноябрь » 27 » Простое число
|
#include <iostream>
using namespace std;
int simple(int x);
bool simple2(int x);
int main(){
int a;
cout<<"Vvedite chislo "; cin>>a;
if (simple2(a)) cout<<"Chislo Prostoe"<<endl;
else cout<<"Chislo NeProstoe"<<endl;
system("pause");
return 0;
}
bool simple2(int x){
int flag=true;
for (int d=2;d<=x/2;d++)
if (x%d==0) {flag=false; break;}
return flag;
}
int simple(int x){
int res=0;
for (int d=1;d<=x;d++)
if (x%d==0) res++;
return res;
}
|
Просмотров: 242 |
Добавил: denjes
| Рейтинг: 0.0/0 |