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:AC过的

Posted by xuzhao20041006 at 2010-07-20 10:50:24 on Problem 3750
In Reply To:AC过的 Posted by:1046755480 at 2010-07-20 04:43:32
> #include<stdio.h>
> #include<stdlib.h>
> #include<string.h>
> 
> typedef struct Node
> {
> 	struct Node *next,*pred;
> 	char    data[16];
> }Node,*LinkList;
> 
> void main()
> {
> 	LinkList p,q,head,r;
> 	int i,j=0,m,n,k=1;char str[16];
> 	int Length;
> 	scanf("%d%*c",&i); Length=i;
> 	p=head=(LinkList)malloc(sizeof(Node));
> 	while(j!=i)
> 	{
> 		j++;
> 		gets(str);
> 		strcpy(p->data,str);
> 		p->next=(LinkList)malloc(sizeof(Node));
> 		p->next->pred=p;
> 		q=p;
> 		p=p->next;
> 	}
> 	free(q->next);q->next=head; head->pred=q;
> 	scanf("%d,%d",&m,&n);
> 
>     j=n;
>     p=head;
> 	for(i=1;i!=m;i++)
> 		head=head->next;
> 	p=head;
> 
> 	while(Length!=0)
> 	{	
> 			
> 		if(k%n==0)
> 		{	
> 			r=p;
> 			Length--;
> 			p->pred->next=p->next;p->next->pred=p->pred;
> 			printf("%s\n",p->data);p=p->next;k++;
> 			free(r);
> 		}
> 		else {p=p->next;k++;}
> 	}   
> } 

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