Advertisement
Guest User

СУКА

a guest
Oct 16th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. bool CEL(int x) {                      // простое или нет
  5.     int i;
  6.     for (i = 2; i < sqrt(x); i++) {
  7.         if (x % i == 0) {
  8.             return (false);
  9.         }
  10.     }
  11. }
  12.  
  13. int main() {
  14.     setlocale(LC_ALL, "rus");
  15.     try {
  16.         int x;
  17.         cout << "Введите число: ";
  18.  
  19.         cin >> x;
  20.  
  21.         if (!cin) {
  22.  
  23.             throw "Введите целое число";
  24.  
  25.         }
  26.  
  27.     }
  28.     catch (const char* errorString) {
  29.  
  30.         cerr << endl << errorString << endl << endl;
  31.         system("pause");
  32.         return -1;
  33.  
  34.     }
  35.  
  36.     cout.setf(ios::boolalpha);
  37.     cout << endl << "Число простое:" << CEL << endl << endl;
  38.     system("pause");
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement