/**
* <p>Filename: Calculation.java</p>
* <p>Copyright:Copyright(c)2009</p>
* @author 楚雄好地方
* @version 200907
* */
//智能联想输出系统。当输入大,出现1.于 2.学,根据选择将结果显示在屏幕
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Input {
public static String[] getArray() {
String[] list = { "大于", "计算", "编程", "编译" ,"中国","楚雄","昆明理工","大学"};
return list;
}
public static void main(String[] args) {
String[] list = getArray();
System.out.println("请输入一个汉字:");
// System.out.println("\n");
InputStreamReader in = null;
BufferedReader br = null;
in = new InputStreamReader(System.in);// 这里可以输入多个汉字;
br = new BufferedReader(in);
String str = "";
try {
str = br.readLine();// 从输入流in中读入一行,并将读取的值赋值给字符串变量str
} catch (IOException e) {
e.printStackTrace();
}
// System.out.println("输入的:" + str);
String[] temp = new String[100];
int count = 0, tempCount = 0;
boolean flag = false;
if(str!=null&&str.length()>0)
for (int i = 0; i < list.length; i++) {
if (list[i].indexOf(str.trim().substring(0, 1)) >= 0)
{// 这里只取第一个
temp[count] = list[i];
flag = true;
count++;
}
}
if (flag) {
System.out.println("已找到对应词汇,请输入对应的编号:");
for (int i = 0; i < temp.length; i++) {
if (temp[i] != null) {
System.out.print((i + 1) + "." +
temp[i].replace(str, "") + " ");
tempCount++;
}
}
System.out.println("");
String str1="";
InputStreamReader in1 = null;
BufferedReader br1 = null;
in1 = new InputStreamReader(System.in);// 这里可以输入多个汉字;
br1 = new BufferedReader(in1);
try {
str1 = br1.readLine();
} catch (IOException e) {
e.printStackTrace();
}
int co=Integer.parseInt(str1);
if (co <= tempCount && co >= 1) {
System.out.println(temp[co-1].replace
(str, ""));
} else {
System.out.println("请输入正确的编号!");
}
}else{
System.out.println("没有找到--("+str+")");
}
}
}











留言