package Hash;import java.io.*;public class HashTableApp {public static void main(String[] args) throws IOException {int aKey,size,n,keysPerCell;System.out.print("Enter size of hash tabl:");size = getInt();System.out.print("Enter initial number of hash tabl:");n = getInt();keysPerCell = 10;HashTable theHashTable = new HashTable(size);for(int j=0;j<n;j++) {aKey = (int) (java.lang.Math.random()*keysPerCell*size);theHashTable.insert(aKey);}while(true) {System.out.println("Enter first letter of");System.out.println("show,insert or find");char choice = getChar();switch(choice) {case 's':theHashTable.displayTable();break;case 'i':System.out.println("插入的值:");aKey = getInt();theHashTable.insert(aKey);break;case 'f':System.out.println("查找的值:");aKey = getInt();boolean found = theHashTable.find(aKey);if(found) {System.out.println("找到值:"+aKey);}}}}public static String getString() throws IOException{InputStreamReader isr = new InputStreamReader(System.in);BufferedReader br = new BufferedReader(isr);String s = br.readLine();return s;}public static char getChar() throws IOException {String s = getString();return s.charAt(0);}public static int getInt() throws IOException {String s = getString();return Integer.parseInt(s);}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。