Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这题是拿来练习栈和队列的# include<stdio.h> # include<string.h> # include<stack> # include<queue> using namespace std; typedef struct Node { char name[40]; }hehe; int main() { hehe A;int i,n,j=0; stack<hehe> p; queue<hehe> q; while(scanf("%d",&n),n) { j++; for(i=0;i<n;i++) { scanf("%s",A.name); if(i%2==0) q.push(A); else p.push(A); } printf("SET %d\n",j); while(!q.empty()) { A=q.front();q.pop(); puts(A.name); } while(!p.empty()) { A=p.top();p.pop(); puts(A.name); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator