Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- #include <iostream>
- using namespace std;
- void potencije(int broj) {
- int sljed = INT_MAX;
- int powiraj;
- for (int i = 2; i < 10; i++) {
- for (int j = 2; j < 10; j++) {
- powiraj = pow(j, i);
- if (powiraj > broj && powiraj <= sljed) {
- sljed = powiraj;
- cout << powiraj << " " << j << "^" << i << endl;
- break;
- }
- }
- }
- }
- int main() {
- int broj = 0;
- cout << "Unesite broj" << endl;
- cin >> broj;
- cout << "Rezultat je:" << endl;
- potencije(broj);
- system("pause>0");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement