Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int nombre_digits(int n) {
- if (n < 10) return 1;
- else return 1 + nombre_digits(n/10);
- }
- //Pre: Llegeix un enter
- //Post: Obtenim el nombre de dígits
- int main() {
- int n;
- cin >> n;
- cout << nombre_digits(n) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement