csansoon

P2.08 P74398 Número de cifras

Sep 21st, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main() {
  5.    
  6.     int n,b,x;
  7.     cin >> n;
  8.     b=2;
  9.     x=1;
  10.    
  11.     // b^x > n
  12.     while (b<=16) {
  13.        
  14.         while (n>=(pow(b,x))) {
  15.             x++;
  16.         }
  17.        
  18.         cout << "Base " << b << ": " << x << " cifras." << endl;
  19.         x=1;
  20.         b++;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment