1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #include <iostream> using namespace std; /* void push(int n); int pop(); int top=0; int stack[100]; void main() { for(int i=0;i<10;i++) { push(10); cout<<pop()<<endl; } } void push(int n) { stack[top++]=n; } int pop() { int temp; temp=stack[--top]; stack[top]=0; return temp; } */ void add( int n); int addd(); int queue[100]; int head=0; int tail=0; void main() { for ( int i=0;i<10;i++) { int a,b,c; cin>>a; cin>>b; cin>>c; add(a); add(b); add(c); cout<<addd()<<endl; cout<<addd()<<endl; cout<<addd()<<endl; } } void add( int n) { queue[head++]=n; } int addd() { int temp; temp=queue[tail]; for ( int i=0;i<10;i++) { queue[i]=queue[i+1]; } head--; return temp; } |
'Study > C++' 카테고리의 다른 글
토크나이저 - 문제해결기법 튜터링 (0) | 2011.09.29 |
---|---|
볼링게임 (0) | 2011.09.29 |
기말 프로젝트 - 토크나이저 (0) | 2011.09.29 |
퍼즐게임 (0) | 2011.09.29 |
tic tac toe 게임 (0) | 2011.09.29 |