⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wordrevertion.java

📁 用java完成的查字典程序
💻 JAVA
字号:
import java.util.ArrayList;
import java.io.*;
public class WordRevertion{
	public WordRevertion(){
	}
	public ArrayList<String> reverse(String origin){
		int length=origin.length();
		String prototype="";
		ArrayList<String> resultList=new ArrayList();
		resultList.add(origin);
		if(origin.endsWith("s")){
			if(origin.endsWith("ies")){
				prototype=origin.substring(0,length-3)+"y";
				resultList.add(prototype);
			}
			if(origin.endsWith("es")){
				    prototype=origin.substring(0,length-2);
			       	resultList.add(prototype);
			}
			prototype=origin.substring(0,length-1);
			resultList.add(prototype);

		}
		
		if(origin.endsWith("ing")){
			if(origin.charAt(length-4)==origin.charAt(length-5)){
				prototype=origin.substring(0,length-4);
				resultList.add(prototype);
			}
			resultList.add(origin.substring(0,length-2)+"e");
		    resultList.add(origin.substring(0,length-3)+"e");
			resultList.add(origin.substring(0,length-3));
		}
		
		if(origin.endsWith("ed")){
			if(origin.charAt(length-3)==origin.charAt(length-4)){
				prototype=origin.substring(0,length-3);
				resultList.add(prototype);
			}
			if(origin.endsWith("ied")){
				prototype=origin.substring(0,length-3)+"y";
			    resultList.add(prototype);
			}
			resultList.add(origin.substring(0,length-2)+"e");
			resultList.add(origin.substring(0,length-2));
		}
		
		return resultList;				
	}
	public static void main(String[]args){
		WordRevertion wr=new WordRevertion();
		try{
			while(true){
				BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
				String originWord=br.readLine();
				ArrayList resultList=wr.reverse(originWord.trim());
				for(int i=0;i<resultList.size();i++){
					System.out.print(resultList.get(i)+"  ");				
				}
				System.out.println();
				continue;
			}
			
		}catch(IOException e){
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -