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

为什么老是WA?

Posted by 3416 at 2010-07-26 11:10:03 on Problem 3750
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct LinkNode
{
	char name[15];
	struct LinkNode *next;
};

typedef struct LinkNode* Linklist;

int main()
{
	Linklist p;
	int n,w,s;
	Linklist InitRing(int n,Linklist p);
	Linklist DeleteOut(int n,Linklist p,int w,int s);
	scanf("%d",&n);
	getchar();
	p=(Linklist)malloc(sizeof(struct LinkNode));
	p=InitRing(n,p);
	scanf("%d,%d",&w,&s);
    p=DeleteOut(n,p,w,s);
	return 0;
}

Linklist InitRing(int n,Linklist p)
{
	Linklist q1,q2;
	char str[15];
	int i;
	p=q2=(Linklist)malloc(sizeof(struct LinkNode));
	for(i=1;i<n;i++)
	{
		q1=(Linklist)malloc(sizeof(struct LinkNode));
		gets(str);
		strcpy(q2->name,str);
        q2->next=q1;
		q2=q1;
	}
	gets(str);
    strcpy(q1->name,str);
	q1->next=p;
	return p;
}

Linklist DeleteOut(int n,Linklist p,int w,int s)
{
	int i,j;
    Linklist q1,q2;
	q1=p;
	for(i=1;i<w;i++)
		q1=q1->next;
	for(j=0;j<n;j++)
	{
		for(i=1;i<s-1;i++)
			q1=q1->next;
		q2=q1->next;
		q1->next=q2->next;
		printf("%s\n",q2->name);
		free(q2);
		q1=q1->next;
	}
    p=q1;
	return p;
}
在VC6.0里面可以通过,但是在编译的时候会出现Skipping... (no relevant changes detected)是怎么回事?
是不是就因为这个,所以系统出现WA的?

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