JakubKaczmarek_123

zadanie 12

Jan 29th, 2021
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int LICZBA_CYFR(int a);
  5. int main(){
  6. cout << LICZBA_CYFR(10)<<endl;
  7. cout << LICZBA_CYFR(101)<<endl;
  8. cout << LICZBA_CYFR(10123241)<<endl;
  9. cout << LICZBA_CYFR(0)<<endl;
  10. cout << LICZBA_CYFR(1)<<endl;
  11. }
  12. int LICZBA_CYFR(int a){
  13.     if (a == 0) return 1;
  14.     int i = 0;
  15. while (a >= pow(10, i)) i++;
  16. return i;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment