dsfsdfdsfds.
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; }; int main() { int n,m,i; struct node *head,*p,*t; head=(struct node *)malloc(sizeof(struct node )); head->next=NULL; t=head; head->data=1; scanf("%d %d",&n,&m); for(i=2;i<=n;i++) { p=(struct node *)malloc(sizeof(struct node)); p->data=i; p->next=NULL; t->next=p; t=p; } t->next=head; p=t; while(p->next!=p) { for(i=0;i<m-1;i++)p=p->next; p->next=p->next->next; } printf("%d\n",p->data); return 0; }