Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- bool isPrime(int x);
- int main()
- {
- system("mode CON COLS=150 LINES=60");
- cout << "Liste des nombres premiers:" << endl;
- int colonne = 1;
- int lines = 1;
- for (int i = 1200000; i <= 2147483647; i++)
- {
- if (isPrime(i))
- {
- cout << i << " ";
- colonne++;
- if (colonne > 18)
- {
- double percent = (i / 2147483647) * 100;
- cout << "(" << percent << "%)" << endl;
- colonne = 1;
- lines++;
- if (lines > 60)
- {
- lines = 1;
- system("cls");
- }
- }
- }
- }
- system("pause");
- return 0;
- }
- bool isPrime(int x)
- {
- bool _isPrime = true;
- if (x % 2 == 0)
- _isPrime = (x == 2);
- for (int d = 3; d < x; d += 2)
- {
- if (x % d == 0)
- {
- _isPrime = false;
- break;
- }
- }
- return _isPrime;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement