fork(1) download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int n, dzielnik;
  5. bool czy_pierwsza(float liczba, float dzielnik)
  6. {
  7. if (liczba<2) return false;
  8. double a;
  9. a=liczba/dzielnik;
  10. if(trunc(a)==a)
  11. return false;
  12. else if(dzielnik>sqrt(liczba))
  13. return true;
  14. else
  15. return czy_pierwsza(liczba, dzielnik+1);
  16. }
  17. int main()
  18. {
  19. cin>>n;
  20. int liczby[n];
  21. for(int i=1; i<=n; i++)
  22. {
  23. cin>>liczby[i-1];
  24. }
  25. for(int i=1; i<=n; i++)
  26. {
  27. if(czy_pierwsza(liczby[i-1], 2)==true)
  28. cout<<"TAK";
  29. else cout<<"NIE";
  30. if(i!=n)
  31. cout<<endl;
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty