Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication26.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include "stdio.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- int prime(int a){
- if (a > 2 && a % 2 == 0)return false;
- for (int i = 3; i < sqrt(a) + 1; i+=2){
- if (a%i == 0)
- return false;
- }
- return true;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- int number;
- cin >> number;
- while (number < 0)
- cin >> number;
- if (prime(number))
- cout << "YES\n";
- else
- cout << "NO\n";
- for (int i = 100; i < 1000; i++){
- if (prime(i))
- cout << i << " ";
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement