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

📄 wordsearch.java

📁 从给定的字母矩阵中查找给定的字典所包含的字符串
💻 JAVA
字号:
import java.io.*;

/**
 * This is the main class of the WordSearch program. <p>
 * This program reads words form the dictionary file,then 
 * search the word in the matrix. It chooses a letter, search 
 * the upside, downside,leftside and rightside of this letter. <p>
 * If finds the right letter, it goes on,otherwise tries a new start until finds 
 * the word in the matrix or the matrix has been searched all over without the word.
 * See class SearchSolve for the main algorithm of this program. <p>
 *
 * @author Ting Chen  0122070
 * @version 1.0    2003/5/30
 * @see java.util.StringTokenizer
 */
 public class WordSearch 
{
	/**
	* The main method of the class.
	* It counts the whole time used and call the help method to finish
	* the search job.
	*
	* @param args The arguments for the method.
	*/
	public static void main(String[] args) throws IOException 
	{
		BufferedReader br;
		String filename;    
		SearchSolve solve;

		java.util.Date mydate;

		long beginTime,endTime;

		if(args.length!=2)
		{
			System.out.println("Error:please input filename.");
			return;
		}

        filename=args[0];
		
		try
		{
			System.out.println("\n================ your solution begins ================\n");
			// get the begin time
			mydate=new java.util.Date();
			beginTime=mydate.getTime();
			br=new BufferedReader(new FileReader(filename));
			solve=new SearchSolve();
			// pass output file name
			solve.outPutFile = args[1];
			solve.readText(br);
			// get the end time
			mydate=new java.util.Date();
			endTime=mydate.getTime();
			System.out.println("\n================ your solution ends =================\n");
			System.out.println("Time consumed: "+(endTime-beginTime)+" millisecondes.");
		}
		catch (IOException e)
		{
			System.out.println("Error:io error.");
		}     
		
	}
}//end of class

⌨️ 快捷键说明

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