package ch7;
import java.io.*;
public class ch7_7
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader in=new InputStreamReader(System.in);
        BufferedReader buf=new BufferedReader(in);
        int num[]=new int[50];
        int x,a=0,b,c;
        String sc;
        for (x=0;x<=49;x++)
        {
            num[x]=0;
        }
        x=0;
        do 
        {
            
            System.out.println("please type a number,-1 for leave the part");
            sc=buf.readLine();
            c=Integer.parseInt(sc);
            num[x]=c;
            x++;
        }while(num[x-1]!=-1);
        do
        {
            System.out.println("search the data 1~"+(x-1));
            sc=buf.readLine();
            c=Integer.parseInt(sc);
            System.out.println("data "+c+" is "+num[c-1]);
        }while(a<=10);
    }
}

===============

please type a number,-1 for leave the part
2
please type a number,-1 for leave the part
5
please type a number,-1 for leave the part
8
please type a number,-1 for leave the part
-1
search the data 1~3
1
data 1 is 2
search the data 1~3
2
data 2 is 5
search the data 1~3
3
data 3 is 8
search the data 1~3
 

arrow
arrow
    文章標籤
    JAVA
    全站熱搜
    創作者介紹
    創作者 驢子 的頭像
    驢子

    驢子的生活日記

    驢子 發表在 痞客邦 留言(0) 人氣()