| ||||||||||
| 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 | |||||||||
平生第一个指针 AC 0ms为了练指针而练指针。
#include <cstdio>
#include <cstring>
#include <cstdlib>
struct Node{
char str[100];
Node *next,*pre;
};
int N,W,S;
Node *head,*tail,*t;
inline void del(Node *x);
int main(){
int i,j;
scanf("%d%*c",&N);
head=new Node;
tail=head;
for (i=1;i<=N;i++){
gets(tail->str);
tail->next=new Node;
tail->next->pre=tail;
tail=tail->next;
}
tail->pre->next=head;
head->pre=tail->pre;
scanf("%d,%d",&W,&S);
t=head;
for (i=1;i<W;i++)
t=t->next;
for (t=t;t->next!=t;0){
for (i=1;i<S;i++)
t=t->next;
puts(t->str);
t=t->next;
del (t->pre);
}
puts(t->str);
system("pause");
}
inline void del(Node *x){
x->next->pre=x->pre;
x->pre->next=x->next;
delete x;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator