Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //matrice m linii n coloane. sa se afiseze linia sau liniile care au nr max de numere palindromice
- //m=4 n=5
- #include <iostream>
- using namespace std;
- int main()
- {
- int a[100][100],m,n,i,j,nr,max=-99999,v[100],x,p;
- cout<<"linile m= "; cin>>m;
- cout<<"coloanele n= "; cin>>n;
- for (i=1;i<=m;i++)
- for (j=1;j<=n;j++)
- {
- cout<<"a["<<i<<"]["<<j<<"]= ";
- cin>>a[i][j];
- }
- for (i=1;i<=m;i++)
- {
- p=1;
- for (j=1;j<=n;j++)
- {
- nr=a[i][j];
- x=0;
- while (nr)
- {
- x=x+nr%10;
- nr=nr/10;
- }
- if (nr==a[i][j])
- v[p]=nr;
- p++;
- }
- }
- if (p>max)
- {
- max=p;
- }
- for (i=1;i<=m;i++)
- if (v[i]==max)
- cout<<i<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement