-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinear.java
44 lines (41 loc) · 849 Bytes
/
linear.java
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
42
43
44
import java.io.*;
class linear
{
int n,search,x;
int a[]=new int[8];
void input() throws Exception
{
DataInputStream f=new DataInputStream(System.in);
System.out.println("ENTER THENO OF ELEMENTS:");
n=Integer.parseInt(f.readLine());
System.out.println("ENTER THe elements:");
for(int i=0;i<n;i++)
a[i]=Integer.parseInt(f.readLine());
System.out.println("ENTER THE SEARCHING ELEMENT:");
search=Integer.parseInt(f.readLine());
}
void out()
{
for(int i=0;i<n;i++)
{
if(a[i]==search)
{
System.out.println("THE SEARCHING ELEMENT is found:");
x=1;
}
}
if(x==0)
{
System.out.println(" THE SEARCHING ELEMENT is not found:");
}
}
}
class m
{
public static void main(String v[]) throws Exception
{
linear l=new linear();
l.input();
l.out();
}
}