mazaya

unpangkat

Sep 1st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. // my first c++ program
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     short penentu = 0;
  9.     cout << "[ Program Unpangkat ]\n\n";
  10.     long a;
  11.     cout << "[?] Berapa angkanya: ";
  12.     cin >> a;
  13.     long b;
  14.     cout << "[?] Berapa pangkatnya: ";
  15.     cin >> b;
  16.     long angka = 0;
  17.     while (angka < a / 5)
  18.         {
  19.             if (penentu != 0)
  20.             {
  21.                 break;
  22.             }
  23.             angka += 1;
  24.             long hitung = 1;
  25.             for(long c = 1; c <= b; c++)
  26.             {
  27.                 hitung *= angka;
  28.             }
  29.             if (hitung == a)
  30.             {
  31.                 cout << "[+] Hasilnya " << angka;
  32.                 penentu += 1;
  33.                 break;
  34.             }
  35.         }
  36.         if (penentu == 0)
  37.         {
  38.             cout << "[!] Tidak ada hasil ditemukan";
  39.         }
  40. }
Add Comment
Please, Sign In to add comment