Advertisement
Guest User

Untitled

a guest
Aug 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. Poštujući sve faze procesa programiranja, napisati program koji učitava prirodni broj n. Program treba ispisati najmanji prirodni broj m, veći ili jednak n, koji je potencija nekog prirodnog broja, tj. m = k^l, gdje su k i l ≥ 2 prirodni brojevi.
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. void potencije(int broj) {
  7. int sljed = INT_MAX;
  8. int powiraj;
  9. for (int i = 2; i < 10; i++) {
  10. for (int j = 2; j < 10; j++) {
  11. powiraj = pow(j, i);
  12. if (powiraj > broj && powiraj <= sljed) {
  13. sljed = powiraj;
  14. cout << powiraj << " " << j << "^" << i << endl;
  15. break;
  16. }
  17. }
  18. }
  19. }
  20. int main() {
  21.  
  22.  
  23. int broj = 0;
  24. cout << "Unesite broj" << endl;
  25. cin >> broj;
  26.  
  27. cout << "Rezultat je:" << endl;
  28. potencije(broj);
  29. system("pause>0");
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement