求大佬帮看看数据结果都对为什么提交之后是0分?
查看原帖
求大佬帮看看数据结果都对为什么提交之后是0分?
45970
筱刘丶楼主2020/9/10 20:11
#include<stdio.h>
#include<stdlib.h> 
struct node{
	int date;
	struct node *next;
};
struct node *head,*p,*q;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		q=(struct node *)malloc(sizeof(struct node));
		q->date=i;
		if(i==1)
			head=p=q;
		else{
			p->next=q;
			q->next=head;
			p=q;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m-1;j++){
			p=head; 
			head=head->next;
		}
		printf("%d  ",head->date);
		p->next=head->next;
		head=p->next;
	}
	return 0;
	
}
2020/9/10 20:11
加载中...