blob: cf198160ca57c7f424a4eccc57b52bdd8149d507 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <sstream>
#include "poly.h"
ostream& operator<<(ostream &os, const Poly &p) {
static const char *supers[10] = {
"⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹"
};
os << p[0];
for (int i = 1; i < (int)p.size(); i++) {
if (p[i] < 0) os << " - " << -p[i];
else if (p[i] > 0) os << " + " << p[i];
else continue;
os << "x";
if (i == 1) continue;
ostringstream ss;
ss << i;
string s = ss.str();
for (char c : s) os << supers[c - '0'];
}
return os;
}
|