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 |
怎么就总是RE呢…………#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator