Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int cnt[10];
  5.  
  6. int main() {
  7.     char c;
  8.     while(cin >> c && c != '.') {
  9.         if (c == '.') break;
  10.         cnt[c - '0']++;
  11.     }
  12.  
  13.     bool q = 0;
  14.     int x = -1;
  15.     for (int i = 0; i < 10; i++) {
  16.         if (cnt[i]%2 == 1) {
  17.             if (!q) {
  18.                 q = 1;
  19.                 x = i;
  20.             }
  21.             else {
  22.                 cout << "NO" << endl;
  23.                 return 0;
  24.             }
  25.         }
  26.     }
  27.    
  28.     cout << "YES" << endl:
  29.     string s = "";
  30.     for (int i = 0; i < 10; i++) {
  31.         for (int j = 0; j < cnt[i]/2; j++) {
  32.             s += (char) (i + '0');
  33.         }
  34.     }
  35.  
  36.     cout << s;
  37.     reverse(s.begin(), s.end());
  38.     if (q) cout << x;
  39.     cout << s;
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement