diff --git a/LiberationSans-Regular.ttf b/LiberationSans-Regular.ttf new file mode 100644 index 0000000..c903700 Binary files /dev/null and b/LiberationSans-Regular.ttf differ diff --git a/itos.cpp b/itos.cpp new file mode 100644 index 0000000..eda5887 --- /dev/null +++ b/itos.cpp @@ -0,0 +1,47 @@ +#include "itos.h" +#include +#include + +using std::string; +using std::stack; +using std::abs; + +string itos(int val) +{ + string answer; + stack stk; + int temp; + + if (val < 0) + { + answer += "-"; + val = abs(val); + } + + while (val > 0) + { + temp = val % 10; + stk.push(temp); + val = val / 10; + } + + if (stk.empty()) return "0"; + + while (!stk.empty()) + { + temp = stk.top(); + if (temp == 0) answer += '0'; + else if (temp == 1) answer += '1'; + else if (temp == 2) answer += '2'; + else if (temp == 3) answer += '3'; + else if (temp == 4) answer += '4'; + else if (temp == 5) answer += '5'; + else if (temp == 6) answer += '6'; + else if (temp == 7) answer += '7'; + else if (temp == 8) answer += '8'; + else if (temp == 9) answer += '9'; + stk.pop(); + } + + return answer; +} diff --git a/itos.h b/itos.h new file mode 100644 index 0000000..b7c285f --- /dev/null +++ b/itos.h @@ -0,0 +1,13 @@ +/* itos.h +Converts integer to string +*/ + +#ifndef _ITOS_H_ +#define _ITOS_H_ + +#include +using std::string; + +string itos(int val); + +#endif