Envato Ads

Tuesday, August 20, 2019

Codeforces Solution 71A Way Too Long Words || Codeforces Solution 71A in C language

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. :

  1. #include<stdio.h>
  2. #include<ctype.h>
  3. int main(){
  4. int n,i,m;
  5. char x[6000];
  6. scanf("%d",&n);
  7. for(i=1;i<=n;i++){
  8. scanf("%s",&x);
  9. int l=strlen(x);
  10.  
  11. if(l>10){
  12.  
  13. printf("%c",x[0]);
  14. printf("%d",l-2);
  15. printf("%c\n",x[l-1]);
  16.  
  17. }
  18. else printf("%s\n",x);}
  19. return 0;
  20. }



In python (basically Python 3) Language , the solution should be :

  1. i=input
  2. for _ in [0]*int(i()):
  3. s=i();l=len(s)-2;print([s,s[0]+str(l)+s[-1]][l>8])





No comments:

Post a Comment