#include <bits/stdc++.h>
using namespace std;
int t;
int main()
{
cin >> t;
while(t--)
{
int a[12] = {0};
int n, len = 0;
cin >> n;
if(n == 0)
{
cout << 1 << endl;
continue;
}
while(n)
{
a[++len] = n % 10;
n /= 10;
}
int t = 0;
for(int i = 1; i <= len; i++)
{
a[i] += t;
t = 0;
if(i == len && a[i] <= 0){
len--;
break;
}
if(a[i] == 9) continue;
else if(a[i] >= 1 && a[i] <= 8)
{
a[i]++;
}
else if (a[i] <= 0){
a[i]--;
t += a[i];
a[i] = 9;
}
}
int res = 0;
for(int i = 1; i <= len; i++)
{
res += a[i];
}
cout << res << endl;
}
}
正常分类讨论写的QAQ