| ||||||||||
| 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了#include <stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct element
{
char name[20];
struct element *next;
}stu;
stu * del(stu *head,char *name);
int main(int argc, char *argv[])
{
int n,i,w,s,count,num;
stu *head,*tail,*pt1,*pt2,*pt3,*pt4,*r;
int leng,cou;
scanf("%d",&n);
for(i=0;i<n;i++)
{
tail=(stu *)malloc(sizeof(stu));
scanf("%s",tail->name);
if(i==0)
{
head=tail;
pt1=head;
}
else
{
if(i==n-1)
{
pt1->next=tail;
tail->next=head;
pt1=tail;
}
else
{
pt1->next=tail;
pt1=tail;
}
}
}
scanf("%d,%d",&w,&s);
pt2=head;
count=1;
while(count!=w) /*//pt2用来存放起始数的位置 */
{
pt2=pt2->next;
count++;
}
pt3=pt2;
count=1;
num=n;
leng=n;
cou=leng+(s%leng==0?leng:s%leng);
while(num!=0)
{
pt4=pt3;
pt3=pt3->next;
count++;
if(count==cou)
{
printf("%s\n",pt3->name);
num--;
if(num==0)
break;
leng--;
cou=leng+(s%leng==0?leng:s%leng);
pt4->next=pt3->next;
r=pt3;
//head=del(head,pt3->name);
pt3=pt3->next;
free(r);
count=1;
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator