Skip to content

Instantly share code, notes, and snippets.

@lifez
Created March 28, 2013 16:25
Show Gist options
  • Select an option

  • Save lifez/5264606 to your computer and use it in GitHub Desktop.

Select an option

Save lifez/5264606 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int main(){
int limit;
char word[50];
scanf("%d",&limit);
while (limit>0){
scanf("%s",&word);
if(strlen(word)>10){
printf("%c%d%c\n",word[0],strlen(word)-2,word[strlen(word)-1]);
limit--;
}
else{
printf ("%s\n",word);
limit--;
}
}
}
import java.util.Scanner;
public class waytolongword {
public static void main(String[] arg){
Scanner in = new Scanner(System.in);
int limit;
String word;
limit = in.nextInt();
while (limit>0){
word =in.next();
char[] words = new char[100];
words = word.toCharArray();
if (word.length()>10){
System.out.format("%s%d%s\n",words[0],word.length()-2,words[word.length()-1]);
}
else{
System.out.format("%s\n",word);
}
limit--;
}
}
}
limit = input()
for i in range(limit):
word = raw_input().strip()
if len(word)>10:
print word[0]+str( len(word)-2)+word[-1]
else:
print word
limit =gets.chomp()
limit = limit.to_i
while limit>0
word = gets.chomp()
if word.length>10
print word[0],word.length-2,word[-1]
print "\n"
else
puts word
end
limit-=1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment