??????????????这是我解决代码强制中的“太长字”问题的解决方案。即使我得到了正确的输出,但仍然有人报告它是codeforces问题的错误答案。
https://开头…????????
????在int的for循环里面做这样的事情 - ??
if(words[j].length()<=10) //boundary check { System.out.print(words[j]); } else { System.out.println(words[j].charAt(0).toString() + words[j].length()-2 + words[j].charAt(words[j].length()-1).toString()); }
????问题在于条件,你只是跳过10以下的单词但不考虑精确到10长度的单词。 ??
if(words[j].length()<=10) { System.out.print(words[j]); }
????改变它应该工作的条件。 ??
Because where r you entering string in your program. Once you run, you will get to know. Btw this is the solution of actual problem. public static void main(String[] args){ String str=null; int count=0; Scanner scanner= new Scanner(System.in); System.out.println("enter string :"); str=scanner.nextLine(); for(int i=0; i<str.length(); i++) { count ++; } char first=str.charAt(0); char last=str.charAt(count-1); int num=count-2; System.out.println("abbreviation is :" +first+num+last); }