fork(1) download
  1. #include <iostream>
  2. #include <map>
  3.  
  4. using namespace std;
  5.  
  6. string superscriptNumber(int x) {
  7. static auto superscriptDic = map<char, string> {
  8. {'0', "⁰"},
  9. {'1', "¹"},
  10. {'2', "²"},
  11. {'3', "³"},
  12. {'4', "⁴"},
  13. {'5', "⁵"},
  14. {'6', "⁶"},
  15. {'7', "⁷"},
  16. {'8', "⁸"},
  17. {'9', "⁹"}
  18. };
  19. string result;
  20. for (auto a : to_string(x)) {
  21. result.append(superscriptDic[a]);
  22. }
  23.  
  24. return result;
  25. }
  26.  
  27. int main() {
  28. int x;
  29.  
  30. while (cin >> x) {
  31. cout << "x" << superscriptNumber(x) << "!" << endl;
  32. }
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 3280KB
stdin
1234
30789
5601
stdout
x¹²³⁴!
x³⁰⁷⁸⁹!
x⁵⁶⁰¹!