beephsupreme

make_palindrome.cpp

Aug 24th, 2022 (edited)
1,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     char c;
  7.     string line;
  8.     getline(cin, line);
  9.     istringstream iss(line);
  10.     vector<int> V(26, 0);
  11.     while(iss >> c){
  12.         V[static_cast<int>(c-65)] += 1;
  13.     }
  14.  
  15.     for(auto &v: V) {
  16.         cout << v << " ";
  17.     }
  18.     cout << '\n';
  19.     for(int i{0};i<V.size();i++) {
  20.         if (V[i]!=0) cout << static_cast<char>(i+65) << " ";
  21.         else cout << "* ";
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment