Advertisement
icatalin

problema marti neterm.

May 13th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. //matrice m linii n coloane. sa se afiseze linia sau liniile care au nr max de numere palindromice
  2. //m=4 n=5
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int a[100][100],m,n,i,j,nr,max=-99999,v[100],x,p;
  11. cout<<"linile m= "; cin>>m;
  12. cout<<"coloanele n= "; cin>>n;
  13. for (i=1;i<=m;i++)
  14. for (j=1;j<=n;j++)
  15. {
  16.     cout<<"a["<<i<<"]["<<j<<"]= ";
  17.     cin>>a[i][j];
  18. }
  19. for (i=1;i<=m;i++)
  20. {
  21. p=1;
  22. for (j=1;j<=n;j++)
  23. {
  24. nr=a[i][j];
  25. x=0;
  26. while (nr)
  27. {
  28.     x=x+nr%10;
  29.     nr=nr/10;
  30. }
  31. if (nr==a[i][j])
  32.  
  33. v[p]=nr;
  34. p++;
  35. }
  36. }
  37. if (p>max)
  38. {
  39.     max=p;
  40. }
  41. for (i=1;i<=m;i++)
  42. if (v[i]==max)
  43. cout<<i<<" ";
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement