데블스 캠프 둘째날 큐 코드
~cpp #include <iostream> using namespace std; void show_menu(); void push_num(); void pop_num(); void show_num(); const int Asize = 3; int container[Asize]={0,}; int order=0; int main() { show_menu(); return 0; } void show_menu() { int choice; while(true) { cout << "1 : Push \t 2 : Pop \t 3: Show" << endl; cin >> choice; switch(choice) { case 1 : push_num(); break; case 2 : pop_num(); break; case 3 : show_num(); break; default : cout << "눈 똑바로......" << endl; } } } void push_num() { if (order>=Asize) { cout << "입력 초과" << endl; show_menu(); } cout << "입력 : "; cin >> container[order++]; } void pop_num() { if (order<=0) { cout << "자료 없음" << endl; show_menu(); } for (int i=0 ; i<order-1 ; i++) //이부분만 빼면 container[i] = container[i+1];//스택이랑 같음 container[--order]=0; } void show_num() { cout << "자료 : "; for (int i=0 ; i<order ; i++) cout << container[i] << " "; cout << endl; }