In this section , I am gonna give you the source code of the codeforces solution of the problem 71A Way Too Long Words.
Problem Name: Way Too Long Words
Online Judge: Codeforces.com
The below given code is written in C language. :
Problem Name: Way Too Long Words
Online Judge: Codeforces.com
The below given code is written in C language. :
- #include<stdio.h>
- #include<ctype.h>
- int main(){
- int n,i,m;
- char x[6000];
- scanf("%d",&n);
- for(i=1;i<=n;i++){
- scanf("%s",&x);
- int l=strlen(x);
- if(l>10){
- printf("%c",x[0]);
- printf("%d",l-2);
- printf("%c\n",x[l-1]);
- }
- else printf("%s\n",x);}
- return 0;
- }
In python (basically Python 3) Language , the solution should be :
- i=input
- for _ in [0]*int(i()):
- s=i();l=len(s)-2;print([s,s[0]+str(l)+s[-1]][l>8])
No comments:
Post a Comment