import java.io.*;
public class wordtext
{
public static void main(String[] args)
{
String s=" ";
String w=" ";
System.out.print("input:\n");
try{
BufferedReader in=new BufferedReader(
new InputStreamReader(System.in));
s=in.readLine();}
catch(IOException e){}
System.out.print("input text word!");
try{
BufferedReader in=new BufferedReader(
new InputStreamReader(System.in));
w=in.readLine();}
catch(IOException e){}
int first=0,second=0,end=0;
for(int i=1;i<=s.length();i+=second+1){
second=s.indexOf(" ");
String t=s.substring(first,second);
s=s.substring(second+1);
if(w.equalsIgnoreCase(t))end++;
}
if(end==0)System.out.println("there no "+w);
else System.out.println("there"+end+w);
}
}
输入文章,再输入要查询的单词,统计查询单词出现几次!!
|