为什么我的程序没有向我显示元素在矢量中的位置?

I'm new to std::vector, and I don't know why my C++ program doesn't show me the index of the max digit of a number. For example, if I put 1 and the number is 123, it should show me 2, cause "2" is the index "3" which is the max digit. It always shows me 0. please help me.

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<iterator>

#define IN ios::sync_with_stdio(false); cin.tie(); cout.tie();
#define OUT return 0;

using namespace std;
using ull = unsigned long long int;

vector<int> v;
int n, x, a, p;

void cifmax(int n, int& cif)
{
    if (n < 10)
        cif = n;
    else
    {       
        cifmax(n / 10, cif);
        if (n % 10 > cif)
            cif = n % 10;
    }
}


int main()
{
    IN

        cin >> n;

    fo(0, n)
    {
        vector<int> A;
        short k = 0;
        bool ok = 0;
        cin >> x;
        cifmax(x, a);
        while (x)
            A.emplace_back(x % 10), x /= 10;
        auto it = find(A.begin(), A.end(), a);
        int index = distance(A.begin(), it);
        cout << index;
        ///it shows me 0 every time
    }

    OUT
}