Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
544 B
0
Indexable
Never
#include <iostream>
using namespace std;

int countDigits(int num) {
    int count = 0;
    while (num != 0) {
        num /= 10;
        count++;
    }
    return count;
}

int main() {
    int n;
    cin >> n;

    int maxDigits = 0;
    int maxNum = 0;
    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        int numDigits = countDigits(num);
        if (numDigits > maxDigits) {
            maxDigits = numDigits;
            maxNum = num;
        }
    }

    cout << maxNum << endl;
}
Leave a Comment