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 Belldandy at 2011-08-19 14:55:48 on Problem 3750
#include<stdio.h>
#include<malloc.h>
struct ch
{
	char name[100];
	struct ch *next;
};
int main()
{
	int N=0,i=0,w=0,s=0,j=0;
	struct ch *p=NULL,*head=NULL,*NEW=NULL,*q=NULL;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		NEW=(struct ch *)malloc(sizeof(struct ch));
		scanf("%s",&NEW->name);
		if(p==NULL)
		{
			head=NEW;
			p=NEW;
		}
		else
		{
			p->next=NEW;
			p=NEW;
		}
	}
	p->next=head;
	scanf("%d,%d",&w,&s);
	p=head;
	for(i=1;i<w;i++)
	{
		p=p->next;
	}
	q=p;
	for(i=0;i<N;i++)
	{
		for(j=1;j<s;j++)
		{
			q=p;
			p=p->next;
		}
		printf("%s\n",p->name);
		q->next=p->next;
                free(p);//加了这句就RE,删了就AC
		p=q->next;
	}
}

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