Advertisement
icatalin

ElimPalindrom neterminat

Nov 8th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void citire (int n,int v[100])
  6. {
  7.     int i;
  8.     for (i=1;i<=n;i++)
  9.     cin>>v[i];
  10. }
  11.  
  12. void afisare(int n,int v[100])
  13. {
  14.     int i;
  15.     for (i=1;i<=n;i++)
  16.     cout<<v[i]<<" ";
  17. }
  18.  
  19. int palindrom(int x)
  20. {
  21.     int xx,nr=0,i;
  22.  
  23.  
  24.     xx=x;
  25.     while (xx)
  26.     {
  27.         nr=nr*10+xx%10;
  28.         xx/=10;
  29.     }
  30.     if (nr==x)
  31.         return 1;//e palindrom
  32.     else
  33.         return 0;//nu e palindrom
  34. }
  35.  
  36. void eliminare()
  37. {
  38.     int m,v[100],n,i,j;
  39.     cin>>n;
  40.     citire(n,v);
  41.  
  42.  
  43.    for (i=1;i<=n;i++)
  44.         {
  45.             if (palindrom(v[i])==1)
  46.             {
  47.             for (j=i;j<=n-1;j++)
  48.             {v[j]=v[j+1];
  49.  
  50.             }
  51.             n--;}
  52.         }
  53.  
  54. for (i=1;i<=n;i++)
  55.     cout<<v[i]<<" ";
  56.  
  57. }
  58.  
  59. int main()
  60. {
  61.     eliminare();
  62.  
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement