_takumi

what2

Feb 26th, 2021 (edited)
215
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string to7(int a) {
  6.     string ans;
  7.     while (a > 0) {
  8.         ans = to_string(a % 7) + ans;
  9.         a /= 7;
  10.     }
  11.     return ans;
  12. }
  13.  
  14. int main() {
  15.     string s;
  16.     cin >> s;
  17.     if ((int)s[0] <= 90 && (int)s[0] >= 65) {
  18.         string str = to_string((int)s[0]);
  19.         s += str;
  20.     }
  21.     if((int)s[s.size() - 1] <= 57 && (int)s[s.size() - 1] >= 48) {
  22.         string ascii = to_string((int)s[s.size() - 1]);
  23.         s = ascii + s;
  24.     }
  25.     for (int i = 0; i < s.size(); i++) {
  26.         cout << to7((int)s[i]);
  27.     }
  28.     return 0;
  29. }
RAW Paste Data