~cpp
#include <iostream>
using namespace std;
const bool TRUE=1;
const bool FALSE=0;
const int MAX_LONG=5;// 5 기.
const int MAX_NUMBER=10000;// 10000기.
class stack
{
private:
char *data_p;
int where_is_save;
int max_size_of_stack;
public:
stack( int data_size )
{
data_p=(char*)malloc(data_size*sizeof(char));
max_size_of_stack=data_size;
where_is_save=0;
}
~stack()
{
free(data_p);
}
bool get_in(char save_data)
{
if (where_is_save != max_size_of_stack)
{
*(data_p+where_is_save)=save_data;
++where_is_save;
return TRUE;
}
else
return FALSE;
}
bool get_out(char *where_save_p )
{
if (where_is_save)
{
--where_is_save;
*where_save_p=*(data_p+where_is_save);
return TRUE;
}
return FALSE;
}
void clear_data()
{
where_is_save=0;
}
};
void main()
{
// 기
const char NUMBER_TO_HAN[10][3]={"","","","","","","","","","구"};
const char NUMBER_TO_JARI[5][3]={"","","","",""};
stack print_number(MAX_LONG);
int input_number=-1;
char jari=-1;
//
while (input_number<0 || input_number>=MAX_NUMBER)
{
system("CLS");
cout << " : ";
cin >> input_number;
}
//
while (input_number>0)
{
print_number.get_in(input_number%10);
input_number/=10;
++jari;
}
//
cout << " : ";
char temp;
if (jari==-1)
cout << NUMBER_TO_HAN[0];
while (print_number.get_out(&temp))
{
if (temp!=0)
cout << NUMBER_TO_HAN[temp] << NUMBER_TO_JARI [jari];
--jari;
}
}