Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
                                                        C++ Programming
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  const int MAX = 10;
  int t;
  cin>>t;
  int n;
  while(t--){
    cin>>n;
    int arr[MAX];
    int r = log10(n);
    int tmp = 0;
    for (int i = 0; i < r+1; i++) {
      tmp = tmp * 10 + 1;
    }
    cout<<(r * 9 + n / tmp)<<endl;
  }
  return 0;
}Input
                                                            6
1
2
3
4
5
100
                                                    1
2
3
4
5
100
Output
                                                            1
2
3
4
5
18
                                                    2
3
4
5
18
Demonstration
Codeforcess Solution 1520-B B. Ordinary Numbers ,C++, Java, Js and Python,1520-B B.Codeforcess Solution
