首页 > 代码库 > 简单查找

简单查找

java实现

package sort;public class SimpleSearch {    /**     * @param args     */    public static void main(String[] args) {        // TODO Auto-generated method stub        int[] arr={70,80,31,37,10,1,48,60,33,80};                System.out.print(simpleSearch(arr, 31));    }        public static int simpleSearch(int arr[],int element){                int i;                for(i=0; i<arr.length; i++)        {            if(arr[i]==element)                return i;        }                return -1;    }    }

 

简单查找