-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA96.java
More file actions
52 lines (46 loc) · 829 Bytes
/
A96.java
File metadata and controls
52 lines (46 loc) · 829 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
42
43
44
45
46
47
48
49
50
51
52
import java.util.Scanner;
class A96
{
public static void main(String[] args)
{
int a[] = {2,3,7,8,10,9};
int b[] = new int[a.length];
int count = 0;
System.out.println("------ REVERSE OF ARRAY and Check it is PALINDROME or not ------"+a.length);
int j = a.length-1;
for (int i=0;i<a.length ;i++ )
{
if (i<=j)
{
int temp =a[i];
a[i] = a[j];
a[j] = temp;
if (a[i]==a[j])
{
b[i]=a[i];
b[j]=a[i];
}
j--;
}
}
for (int k=0;k<a.length ;k++ )
{
System.out.print(a[k] + " ");
}
for (int l=0;l<a.length ;l++ )
{
if (a[l]==b[l])
{
count++;
}
}
if(count==a.length)
{
System.out.println("IT is Palindrome");
}
else
{
System.out.println("IT is NOT Palindrome");
}
}
}