SHARE
TWEET

Anagramy ABC

a guest Mar 26th, 2020 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. bool ana (string s1, string s2) {
  5.     if (s1.size() != s2.size()) {
  6.         return false;
  7.     }
  8.     int Ts[2][3];
  9.     Ts[0][0] = 0;
  10.     Ts[0][1] = 0;
  11.     Ts[0][2] = 0;
  12.     Ts[1][0] = 0;
  13.     Ts[1][1] = 0;
  14.     Ts[1][2] = 0;
  15.     int i = 0;
  16.     while (true) {
  17.         if (int(s1[i]) == 0) {
  18.             break;
  19.         } else {
  20.             Ts[0][int(s1[i])-65]++;
  21.             Ts[1][int(s2[i])-65]++;
  22.         }
  23.         i++;
  24.     }
  25.     if (Ts[0][0] == Ts[1][0] && Ts[0][1] == Ts[1][1] && Ts[0][2] == Ts[1][2]) {
  26.         return true;
  27.     }
  28.     return false;
  29. }
  30. int main () {
  31.     string s1;
  32.     cin >> s1;
  33.     string s2;
  34.     cin >> s2;
  35.     cout << ana (s1, s2);
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top