
用java编写一段代码获取下面文章中的单词(长度在5-15之间,并且c在o前面)并将其显示出来拜托各位大神
TheLibraryofCongresswasin1800.ItstartedwithelevenboxesofbooksinoneroomoftheCapitolBui...
The Library of Congress was in 1800. It started with eleven boxes of books in one room of the Capitol Building. By 1814, the collection had increased to about 3,000 books. They were all that year when the Capitol was burned down during America’s war with Britain.
展开
展开全部
将那段文章放在文件内,然后用IO流读出来 或者直接String s = 上面那段 然后 StringTokenizer st = new StringTokenizer(s," "); String temp; while(st.hasNext()){ temp = st.next(); if(temp.length()>=5 && temp.length()<=15){ for(int i = 0; i < temp.length()-1; i++){ if(temp.toChar(i) == 'c') if(temp.toChar(i+1) == 'o') System.out.println(temp); } } 大体思路是这样. }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询