-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2DPALIND.CPP
More file actions
42 lines (40 loc) · 846 Bytes
/
2DPALIND.CPP
File metadata and controls
42 lines (40 loc) · 846 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
//Function - To find the palindrome numbers in the entered matrix
#include<iostream.h>
#include<conio.h>
void palin (int a[][30],int,int);
void main()
{int a[30][30],p,q,i,j;
clrscr();
cout<<"Enter the dimension of the matrix "<<endl;
cin>>p>>q;
cout<<"Enter the elements of the matrix ";
for(i=0;i<p;i++)
{ for (j=0;j<q;j++)
cin>>a[i][j];
}
cout<<"The matrix you entered is ";
for(i=0;i<p;i++)
{ cout<<endl;
for(j=0;j<q;j++)
cout<<a[i][j]<<'\t';
}
palin(a,p,q);
getch();
}
void palin (int a[][30],int p,int q)
{ int dig,rev=0,z;
cout<<endl<<"The palindrome numbers in the matrix are ";
for(int i=0;i<p;i++)
{ for(int j=0;j<q;j++)
{ z=a[i][j];
rev=0;
while(a[i][j]!=0)
{dig=a[i][j]%10;
rev=dig+(10*rev);
a[i][j]=(a[i][j]/10);
}
if(rev==z)
cout<<endl<<'\t'<<z;
}
}
}