Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
4c
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' //Lokeshreddy 7002 import java.util.*; import java.lang.*; class Rextester { public static void main(String[] args) { int n, x, flag = 0, i = 0; Scanner s = new Scanner(System.in); System.out.print("\nNumber of elements to be entered:"); n = s.nextInt(); int a[] = new int[n]; System.out.println("\nThe list of elements:"); for(i = 0; i < n; i++) { a[i] = s.nextInt(); } System.out.print("\nEnter the element to find:"); x = s.nextInt(); for(i = 0; i < n; i++) { if(a[i] == x) { flag = 1; break; } else { flag = 0; } } if(flag == 1) { System.out.println("\nElement found at position:"+(i + 1)); } else { System.out.println("\nElement not found"); } } }
run
|
edit
|
history
|
help
0
First Interview question - Java
do whilee
메소드구현하기-해결
Кошачья бойня
add static
Thread counter
Union of Arrays
get top k frequent elements ( Priority Queue implementation )
Hello, World!
kth smallest element