Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- using namespace std;
- int main()
- {
- int n, m, i, j;
- int dzie = 0, sto = 0, tys = 0, tyss = 0, tysss = 0, mil = 0;
- cout << "Podaj minimum: ";
- cin >> n;
- cout << "Podaj maximum: ";
- cin >> m;
- int tab[m+1];
- for (i = 0; i <= m+1; i++)
- {
- tab[i] = i;
- }
- for (i = 2; i*i <= m+1; i++)
- {
- if (tab[i] != 0)
- {
- for (j = 2*i; j <= m; j+= i)
- {
- tab[j] = 0;
- }
- }
- }
- cout << "Liczby pierwsze od ," << n << "do" << m << " to:" << endl;
- for (i = n; i <= m; i++)
- {
- if (tab[i] != 0)
- {
- cout << tab[i] << " ";
- cout << endl;
- if ((i > 9) && (i < 100))
- {
- dzie++;
- }
- if ((i > 99) && (i < 1000))
- {
- sto++;
- }
- if ((i > 999) && (i < 10000))
- {
- tys++;
- }
- if ((i > 9999) && (i < 100000))
- {
- tyss++;
- }
- if ((i > 99999) && (i < 1000000))
- {
- tysss++;
- }
- if ((i > 999999) && (i < 10000000))
- {
- mil++;
- }
- }
- }
- cout << "10-100 = " << dzie << endl << "100-1000 = " << sto << endl << "1000-10000 = " << tys << endl << "10000-100000 = " << tyss << endl << "100000-1000000 = " << tysss << endl << "1000000-10000000 = " << mil << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement