-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrpalendrome.java
More file actions
56 lines (52 loc) · 1.3 KB
/
Copy patharrpalendrome.java
File metadata and controls
56 lines (52 loc) · 1.3 KB
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
53
54
55
56
package array;
import java.util.Scanner;
import java.lang.Math;
public class arrpalendrome {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int flag=0,n,count=0;
System.out.println("enter no. of elements: ");
n=s.nextInt();
int ar[]=new int[n];
for(int i=0;i<n;i++)
{
System.out.println("enter element: "+i);
ar[i]=s.nextInt();
}
for(int i=0;i<n;i++)
{
int b=0;
int sum=0;
int temp=ar[i];
int temp2=temp;
count=0;
while(temp!=0)
{
count++;
temp=temp/10;
}
while(temp2!=0)
{
b=temp2%10;
sum=sum*10+b;
temp2=temp2/10;
}
if(sum==ar[i])
{
flag=0;
}
else{
flag=1;
break;
}
}
if(flag==1)
{
System.out.println("its not a palendrome array");
}
else
{
System.out.println("its a palendrome array");
}
}
}