fork(3) download
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int SprawdzLiczbe(int p)
  10. {
  11. int r = sqrt(p);
  12. int i = 2;
  13.  
  14. if (p==1) return 0;
  15.  
  16.  
  17. while (i<=r) if(!(p%i++)) return 0;
  18. return 1;
  19.  
  20.  
  21. }
  22.  
  23. int main()
  24. {
  25. int p, a, c;
  26. cin >>a;
  27. if (a>=100000) return 0;
  28. for (c = 1; c<=a; c++)
  29. {
  30. cin >> p;
  31. if ((p>10000)||(p<=0)) return 0 ;
  32.  
  33.  
  34.  
  35. if (SprawdzLiczbe(p))
  36. cout <<"tak" <<endl;
  37. else
  38. cout <<"nie" <<endl;
  39.  
  40. }
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Standard output is empty