Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这题是拿来练习栈和队列的

Posted by 211406212 at 2015-07-21 16:31:56 on Problem 2013
# 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator