. Повернутися

int PosLastMinDig(int n)
{
    if (n<=0) return -1;
    int minDigit=9, position=0, currentPos=0;
    int temp=n;
    while (temp>0)
    {
        currentPos++;
        temp/=10;
    }
    currentPos=0;
    while (n>0)
    {
        int digit=n%10;
        currentPos++;
        if (digit<minDigit)
        {
            minDigit=digit;
            position=currentPos;
        }
        n/=10;
    }
    return position;
}