Advertisement
patryk178

Untitled

Sep 23rd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. bool sprawdz(string n1, string n2, int dl)
  7. {
  8.     int n = dl-1;
  9.     int t1[3] = {0};
  10.     int t2[3] = {0};
  11.     for(int i=0;i<=dl/2;i++)
  12.     {
  13.         if(n1[i]=='A')t1[0]++;
  14.         else if(n1[i]=='B')t1[1]++;
  15.         else t1[2]++;
  16.  
  17.         if(n2[i]=='A')t2[0]++;
  18.         else if(n2[i]=='B')t2[1]++;
  19.         else t2[2]++;
  20.  
  21.         if(n>dl/2)
  22.         {
  23.             if(n1[n]=='A')t1[0]++;
  24.             else if(n1[n]=='B')t1[1]++;
  25.             else t1[2]++;
  26.  
  27.             if(n2[n]=='A')t2[0]++;
  28.             else if(n2[n]=='B')t2[1]++;
  29.             else t2[2]++;
  30.         }
  31.  
  32.         n--;
  33.     }
  34.     for(int i=0;i<3;i++)
  35.     {
  36.         cout<<t1[i]<<t2[i]<<",";
  37.         if(t1[i]!=t2[i])return false;
  38.     }
  39.     return true;
  40.  
  41. }
  42.  
  43. int main()
  44. {
  45.     string n1 = "ACACCBC";
  46.     string n2 = "ACCBBCA";
  47.     int dl1 = n1.size();
  48.     int dl2 = n2.size();
  49.     if(dl1==dl2)cout<<sprawdz(n1,n2,dl1);
  50.     else cout<<0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement