GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Array-Programs/SearchKeyElement.java at master · iambhat/Array-Programs Expand file tree/ Copy pathSearchKeyElement.javaMore file actions 41 lines (37 loc) · 946 Bytes / Copy pathSearchKeyElement.javaFile metadata and controls41 lines (37 loc) · 946 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 package arrays; import java.util.Scanner; class SearchElement{ int flag,index; Scanner sc = new Scanner(System.in); void display(int[] a,int key) { for(int i=0;i<a.length;i++) { if(key == a[i]) { flag = 1; index = i; break; } } if(flag == 0) System.out.println("Element not Found!!"); else System.out.println("Element found at the position : "+index); } public void readArray() { System.out.println("Enter the array size :"); int n = sc.nextInt(); int[] a = new int[n]; System.out.println("Enter the array elements"); for(int i=0;i<n;i++) a[i] = sc.nextInt(); System.out.println("Enter the key elemenent to be searched:"); int key = sc.nextInt(); display(a,key); } } public class SearchKeyElement { public static void main(String[] args) { // TODO Auto-generated method stub SearchElement se = new SearchElement(); se.readArray(); } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |