#include<stdio.h>
#include
<stdlib.h>

typedef 
struct node* link;
struct node{int item; link next;};

int main()
{  
   
int i,N,M;
   scanf(
"%d%d",&N,&M);
   link t
=malloc(sizeof *t),x=t;
   t
->item=1;t->next=t;
   
for(i=2; i<=N; i++){
         x
=(x->next=malloc(sizeof *x));
         x
->item=i; x->next=t;
       }
       
      
while(x!=x->next){
           
for(i=1; i<M; i++) x=x->next;
           x
->next=x->next->next;N--;
          
          }
          printf(
"%d\n",x->item);
      
return 0;
}

 

相关文章:

  • 2022-12-23
  • 2021-02-17
猜你喜欢
  • 2021-11-18
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
相关资源
相似解决方案