Advertisement
Trawka011

Untitled

Oct 13th, 2022
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. long int sum;
  4. int f(long int n) {
  5.     if (n == 0) {
  6.         if (sum == 0) {
  7.             return 1;
  8.         }
  9.         return sum;
  10.        
  11.     }
  12.     sum++;
  13.     return f(n / 10);
  14.    
  15. }
  16. int main() {
  17.     long int n;
  18.     cin >> n;
  19.     cout << f(n);
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement