Advertisement
TwiNNeR

MY PRIDE

Mar 3rd, 2014
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main()
  8. {
  9.     cout<<"Vnesete n ";
  10.     int n;
  11.     cin>>n;
  12.  
  13.     int a[n];
  14.     cout<<"Vnesete ja nizata: ";
  15.     for(int i=1;i<=n;i++)
  16.     {
  17.         cin>>a[i];
  18.     }
  19.  
  20.     int br=1;
  21.     bool prekin=true;
  22.     for(int i=1;i<=n;i++)
  23.     {
  24.         for(int j=i;j<=n;j++)
  25.         {
  26.             prekin=false;
  27.             if(a[i]==a[j])
  28.             {
  29.  
  30.                 int lj=j;
  31.                 for(int zh=i;zh<=j/2;zh++)
  32.                 {
  33.                     if(a[zh]==a[lj])
  34.                     {
  35.                         prekin=true;
  36.                         lj--;
  37.                     }
  38.                     else
  39.                     {
  40.                         prekin=false;
  41.                         break;
  42.                     }
  43.  
  44.                 }
  45.  
  46.                     if(prekin)
  47.                     {
  48.                         for(int k=i;k<=j;k++)
  49.                         {
  50.                             cout<<a[k]<<", ";
  51.                         }
  52.                             cout<<endl;
  53.                     }
  54.  
  55.  
  56.             }
  57.         }
  58.  
  59.     }
  60.  
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement