fork download
  1. #include<iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. void SieveOfEratosthenes(int n,int z)
  6. {
  7. // Create a boolean array "prime[0..n]" and initialize
  8. // all entries it as true. A value in prime[i] will
  9. // finally be false if i is Not a prime, else true.
  10. bool prime[n+1];
  11. memset(prime, true, sizeof(prime));
  12.  
  13. for (int p=2; p*p<=n; p++)
  14. {
  15. // If prime[p] is not changed, then it is a prime
  16. if (prime[p] == true)
  17. {
  18. // Update all multiples of p
  19. for (int i=p*2; i<=n; i += p)
  20. prime[i] = false;
  21. }
  22. }
  23. if(z==1)
  24. z=2;
  25. // Print all prime numbers
  26. for (int p=z; p<=n; p++)
  27. if (prime[p])
  28. cout << p << " ";
  29. }
  30.  
  31. // Driver Program to test above function
  32. int main()
  33. {
  34. long int a,b,n,i,k;
  35. cin>>n;
  36.  
  37. for(k=0;k<n;k++)
  38. {
  39. cin>>a>>b;
  40. SieveOfEratosthenes(b,a);
  41. }
  42. return 0;
  43. }
  44.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2
1 10
3 5
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.4/py_compile.py", line 124, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "./prog.py", line 3
    using namespace std;
                  ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.4/py_compile.py", line 128, in compile
    raise py_exc
py_compile.PyCompileError:   File "./prog.py", line 3
    using namespace std;
                  ^
SyntaxError: invalid syntax

stdout
Standard output is empty