Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

丁霆霄(链表倒序)已改 #7

Open
dtxdtx opened this issue Nov 25, 2018 · 3 comments
Open

丁霆霄(链表倒序)已改 #7

dtxdtx opened this issue Nov 25, 2018 · 3 comments
Labels
通过 代码通过考核

Comments

@dtxdtx
Copy link

dtxdtx commented Nov 25, 2018

No description provided.

@dtxdtx dtxdtx closed this as completed Nov 25, 2018
@dtxdtx
Copy link
Author

dtxdtx commented Nov 25, 2018

#include<stdio.h>
#include<stdlib.h>
#define L sizeof(struct S)
struct S
{
	int num;
	int score;
	struct S *next;
};
int n;
struct S *creat()
{
	struct S *head;
	struct S *p1,*p2;
	head=NULL;
	p1=p2=(struct S*)malloc(L);
	printf("输入链表(以0 0结束)\n");
	scanf("%d%d",&p1->num,&p1->score);
	n=0;
	while(p1->num!=0)
	{
		n=n+1;
		if(n==1)head=p1;
		else
		{
			p2->next=p1;
		}
		p2=p1;
		p1=(struct S*)malloc(L);
		scanf("%d%d",&p1->num,&p1->score);
	}
	p2->next=NULL;
	return head;
}
struct S *unsort(struct S *head)
{
	struct S *p1,*p2;
	p1=head->next;
	p2=head;
	p2->next=NULL;
	if(p1==NULL)return head;
	if(p1->next==NULL)
	{
		head=p1;
		p1->next=p2;
		return head;
	}
	while(p1->next!=NULL)
	{
		head=p1->next;
		p1->next=p2;
		p2=p1;
		p1=head;
	}
	p1->next=p2;
	return head;
}
void print(struct S *head)
{
	struct S *p;
	p=head;
	while (p!=NULL)
	{
		printf("%d %d\n",p->num,p->score);
		p=p->next;
	}
}
int main()
{
	struct S *head;
	head=creat();
	head=unsort(head);
	print(head);
	return 0;
}

@dtxdtx
Copy link
Author

dtxdtx commented Nov 25, 2018

No description provided.

@dtxdtx dtxdtx reopened this Nov 25, 2018
@wmpscc
Copy link
Member

wmpscc commented Dec 7, 2018

点评:

  • 未对链表实际内容操作,请改正
  • 建议增加输入引导

请修改!

@wmpscc wmpscc added 未通过 修改 代码出现问题,请修改后重新提交代码 and removed 未通过 labels Dec 7, 2018
@dtxdtx dtxdtx changed the title 丁霆霄(链表倒序) 丁霆霄(链表倒序)已改 Jan 14, 2019
@wmpscc wmpscc added 通过 代码通过考核 and removed 修改 代码出现问题,请修改后重新提交代码 labels Feb 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
通过 代码通过考核
Projects
None yet
Development

No branches or pull requests

2 participants