Code Review

c-plus-plus
codeforces

#1

I am trying to solve this problem on CodeForces. I came up with a solution and submitted it. However it is showing wrong answer on both testcases though it works completely fine on my system. Is anything wrong with the solution below? :

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <iostream>

using namespace std;
int main(int argc,const char *argv[]){
    string userInput;
    int t;
    scanf("%d",&t);
    while(t--){
	    cin >> userInput;
	    if(userInput.length()<10){
		cout << userInput << "

";
}
else{
int n = userInput.length() - 2;
cout << userInput[0] << n << userInput[n+1] << "
";
}
}
return 0;
}


#2

@vigonoid , in the problem , it is mentioned that if the length strictly more than 10 characters , only then you have to change it. So, instead of “userInput.length()<10”, use “userInput.length()<=10”.


#3

@sanjeev1779 Thanks! I got it :slight_smile: