71A - Way Too Long Words || Codeforces

Problem name: 71A - Way Too Long Words

Judge: Codeforces

Problem link: 71A - Way Too Long Words

Solution on GitHub: 71A - Way Too Long Words

 

[At first you should try to solve the problem on your own. This will increase your thinking power and the ability to solve the program will increase. And if you copy directly from here, you will not learn anything. So my advice is to try to solve it yourself first. If not then check this code. Once you understand the code, do it yourself. Don't copy from here.
Best of luck]

 

Codeforces 71A - Way Too Long Words Solution in Java

import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        for (int i = 1; i <= n; i++) {
            String word = input.next();
            if (word.length() > 10) {
                int value = word.length() - 2;
                System.out.println(word.charAt(0) + "" + value + "" + word.charAt(word.length() - 1));
            }
            else System.out.println(word);
        }
    }
}







 

 

Next Post Previous Post
No Comment
Add Comment
comment url