Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. cout << "Autor: Kacper Malinowski" << endl;
  8. cout << "Tytul: Czy liczba jest pierwsza czy zlozona?" << endl;
  9.  
  10. int n;
  11. int i=2;
  12. char powt;
  13.  
  14. for(;;){
  15.  
  16. cout << "Podaj n: ";
  17. cin >> n;
  18.  
  19. for(;;){
  20.  
  21. if(i==n){
  22. cout << "n jest liczba pierwsza";
  23. break;
  24. }
  25.  
  26. else{
  27. if(n%i==0){
  28. cout << "n jest liczba zlozona";
  29. break;
  30. }
  31. else{
  32. i=i+1;
  33. }
  34. }
  35.  
  36. }
  37.  
  38. cout << endl << "Czy powtorzyc dla innej liczby (T/N): ";
  39. cin >> powt;
  40.  
  41. if(powt=='N'){
  42. break;
  43. }
  44.  
  45. }
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement