fork download
  1. #include <iostream>
  2. #include <sstream>
  3.  
  4. using namespace std;
  5.  
  6. string superscriptNumber(int x) {
  7. static string superscriptDigits[] = {
  8. "⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹"
  9. };
  10. stringstream normal;
  11. normal << x;
  12. string s = normal.str();
  13.  
  14. string result;
  15. for (size_t i=0; i<s.size(); ++i) {
  16. if (isdigit(s[i])) {
  17. result.append(superscriptDigits[s[i]-'0']);
  18. }
  19. }
  20.  
  21. return result;
  22. }
  23.  
  24. int main() {
  25. int x;
  26.  
  27. while (cin >> x) {
  28. cout << "x" << superscriptNumber(x) << "!" << endl;
  29. }
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 3236KB
stdin
123
456
789
1023
stdout
x¹²³!
x⁴⁵⁶!
x⁷⁸⁹!
x¹⁰²³!