Added some new files left out of last commit

This commit is contained in:
Anna Rose 2011-07-01 13:24:02 -04:00
parent 938e75716c
commit d1c11799f4
3 changed files with 60 additions and 0 deletions

BIN
LiberationSans-Regular.ttf Normal file

Binary file not shown.

47
itos.cpp Normal file
View File

@ -0,0 +1,47 @@
#include "itos.h"
#include <stack>
#include <cstdlib>
using std::string;
using std::stack;
using std::abs;
string itos(int val)
{
string answer;
stack<int> 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;
}

13
itos.h Normal file
View File

@ -0,0 +1,13 @@
/* itos.h
Converts integer to string
*/
#ifndef _ITOS_H_
#define _ITOS_H_
#include <string>
using std::string;
string itos(int val);
#endif