/**
 * @(#)sort.java
 * @author: Arthur
 * @version 1.00 2007/10/3
 * @(1)purple sort (2)usual search (3)random值不重複!
 */

import java.io.*;
public class sort {

    public static void main(String args[])throws IOException {
     int a[]=new int[20];
     int i=0,j=0,temp=0;
     for (i=0;i       a[i]=(int)(Math.random()*99+1);
      for (j=0;j        if (a[i]==a[j]){
        i--;
        break;
       }
      }
     }
     for (i=0;i      System.out.println();
     for (i=0;i       for (j=0;j        if (a[i]         temp=a[i];
        a[i]=a[j];
        a[j]=temp;
       }
      }
     }
     for (i=0;i      BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
     System.out.println();
     System.out.print("請輸入一個數字:");
     int input=Integer.parseInt(buf.readLine());
     for (i=0;i       if (input==a[i]){
          j=1; 
       break;
      }
      else
       j=2;
     }
     if (j==1) System.out.println("在第"+(i+1)+"個:a["+i+"]");
     if (j==2) System.out.println("找不到資料!");
    }
   
   
}

創作者介紹
創作者 missice's Blog 的頭像
浮雲

missice's Blog

浮雲 發表在 痞客邦 留言(0) 人氣( 9 )