1. #include<iostream>
  2. using namespace std;
  3. void insert_q(char *q, int &front, int &rear, char c){
  4. if(front==-1){
  5. front++;
  6. }
  7. rear++;
  8. q[rear]=c;
  9. }
  10. void delete_q(char *q, int &front, int &rear){
  11. front++;
  12. }
  13. void print_q(char *q, int front, int rear){
  14. int i;
  15. cout<<"큐의 현재 상태는 아래와 같다"<<endl;
  16. for(i=front;i<rear+1;i++){
  17. cout<<q[i]<<endl;
  18. }
  19. }
  20. int main(){
  21. char q[10];
  22. int front=-1, rear=-1;
  23. insert_q(q, front, rear, 'P');
  24. insert_q(q, front, rear, 'R');
  25. insert_q(q, front, rear, 'B');
  26. delete_q(q, front, rear);
  27. delete_q(q, front, rear);
  28. insert_q(q, front, rear, 'J');
  29. insert_q(q, front, rear, 'G');
  30. insert_q(q, front, rear, 'K');
  31. insert_q(q, front, rear, 'S');
  32. print_q(q, front, rear);
  33. return 0;
  34. }

 

Posted by 도전하는 공돌이pooh

댓글을 달아 주세요