Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. void a (vector <int> * vec)
  8. {
  9.     int x = (*vec)[(*vec).size()-1];
  10.    
  11.     for (int i = (*vec).size()-1; i > 0; --i)
  12.         (*vec)[i] = (*vec)[i-1];
  13.    
  14.     (*vec)[0] = x;
  15.    
  16.     return;
  17. }
  18.  
  19. void b (vector <int> * vec)
  20. {
  21.     int x = (*vec)[2];
  22.    
  23.     for (int i = 2; i > 0; --i)
  24.         (*vec)[i] = (*vec)[i-1];
  25.    
  26.     (*vec)[0] = x;
  27.    
  28.     return;
  29. }
  30.    
  31.    
  32.  
  33. void wypisz (vector <int> wektor)
  34. {
  35.     for (int i = 0; i < wektor.size(); ++i)
  36.         printf("%i", wektor[i]);
  37.     printf("\n");
  38.     return;
  39. }
  40.  
  41. int pozycja (vector <int> wektor, int szukana)
  42. {
  43.     for (int i = 0; i < wektor.size(); ++i)
  44.         if (wektor[i] == szukana) return i;
  45.     return -1;
  46. }
  47.  
  48. int main ()
  49. {
  50.     int n;
  51.     scanf("%i", &n);
  52.     vector <int> tab;
  53.    
  54.     string out("");
  55.    
  56.     for (int i = 0; i < n; ++i)
  57.     {
  58.         int x;
  59.         scanf("%i", &x);
  60.         tab.push_back(x);
  61.     }
  62.    
  63.     for (int i = 2; i <= n; ++i)
  64.     {
  65.         if (pozycja(tab, i) == pozycja(tab, i-1)) continue;
  66.        
  67.         while (pozycja(tab, i) != (pozycja(tab, i-1)+1) || pozycja(tab, i) != (pozycja(tab, i-1)-7))
  68.         {
  69.             while (pozycja(tab, i) != 2)
  70.             {
  71.                 a(&tab);
  72.                 out += "a";
  73.             }
  74.             if (pozycja(tab, i-1) == n-2)
  75.             {
  76.                 a(&tab);
  77.                 out += "a";
  78.                 b(&tab);
  79.                 out += "b";
  80.             }
  81.             else
  82.             {
  83.                 b(&tab);
  84.             }
  85.         }
  86.     }
  87.     counter = 0;   
  88.     for (int i = 0; i < out.length(); ++i)
  89.     {
  90.         int acount = 0, bcount = 0;
  91.         bool isa;
  92.         if (out[i] == 'a')
  93.         {
  94.             acount++;
  95.             if (i == 0)
  96.                 isa = true;
  97.             else if (
  98.            
  99.         else
  100.         {
  101.             bcount++;
  102.             if (
  103.     }
  104.    
  105.     for (int i = 0; i <
  106.    
  107.     return 0;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement