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

怎么就总是RE呢…………

Posted by azazasyb at 2010-02-19 11:08:18 on Problem 3750
#include <iostream>
#include <string>

using namespace std;

struct Node
{
	string name;
	Node* next;
};

int main()
{
	int n, s, w;
	int i, temp;
	char c;
	Node* first;
	Node* last;
	Node* newNode;
	Node* current;

	newNode = new Node;
	first = newNode;
	current = first;

	freopen("cin.txt","r",stdin);   
	freopen("cout.txt","w",stdout);   

	cin>>n;
	for ( i=0; i<n-1; i++ )
	{
		cin>>newNode->name;
		newNode->next = new Node;
		newNode = newNode->next;
	}
	cin>>newNode->name;
	newNode->next = first;

	cin>>w>>c>>s;

	if ( s>n )
		s = s%n;

	w--;
	while ( w-- )
	{
		last = current;
		current = current->next;
	}
	
	while ( n-- )
	{
		temp = s-1;
		while ( temp-- )
		{
			last = current;
			current = current->next;
		}

		cout<<current->name<<endl;
		last->next = current->next;
		current = last->next;
	}

	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