-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCount_palindromes.java
More file actions
45 lines (44 loc) · 849 Bytes
/
Count_palindromes.java
File metadata and controls
45 lines (44 loc) · 849 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
import java.util.*;
class palin
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int c =0;
int arr[] = new int[n];
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
for(int i=0;i<n;i++)
{
if(palin(arr[i])==true)
{
c++;
}
}
System.out.println(c);
}
static boolean palin(int n)
{
int temp=n;
int rev=0;
boolean a = true;
boolean b = false;
while(temp!=0)
{
int d = temp%10;
rev=(rev*10)+d;
temp=temp/10;
}
if(rev==n)
{
return a;
}
else
{
return b;
}
}
}