~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; } }