本文介绍了我需要一个wordcount的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要弄清楚如何制作一个程序来计算用户输入的句子中的单词。用户还输入每个单词必须的长度。因此,如果用户输入5个字母的单词,则该句子包含4个字母的单词;这个词不计算在内。
I need to figure out how to make a program that counts the words in a sentence that the user inputs. The user also inputs the length that each word must be. So, if the user inputs 5 letter words, and the sentence includes a 4 letter word; that word won't be counted.
这就是我所拥有的......
This is all I have...
public class wordcount { public static void main(String[] args) { int length = IO.readInt(); String sentence = IO.readString(); int full = sentence.length(); int wordcount = 0; for(int i = 0; i < length; i++){ } System.out.print(wordcount); } }推荐答案
return sentence.split("\\s+").length;
更多推荐
我需要一个wordcount的程序
发布评论