yuesefuhuan.txt

来自「java j2ee e-book very good」· 文本 代码 · 共 62 行

TXT
62
字号
#include<stdio.h>
#include<stdlib.h>
struct Lnode
{  int number;
    int password;
    struct Lnode *next;
}Lnode,* p,*q,*head;        

f(int n )
{int i;
for(i=1;i<=n;i++)
       { if(i==1)
  {
head=p=(struct Lnode*)malloc(sizeof(struct Lnode));
  if(p==0) return(0);
 }

else
 {
   q=(struct Lnode*)malloc(sizeof(struct Lnode));
if(q==0) return(0);
p->next=q;    
p=q;      
   }
          printf("please enter the %d people's password:",i);
          scanf("%d",&(p->password));        
                p->number=i;   
   }

    p->next=head;  
p=head; 
}
g(int n,int m)
{int j,i;
for (j=1;j<=n;j++)                                                                                                                      
   {
    for(i=1;i<m;i++) p=p->next; 
   m=p->password;
    printf("%d->",p->number);
         p->number=p->next->number;
         p->password=p->next->password; 
         q=p->next;
         p->next=p->next->next;
         free(q); 

   } 

    return 0;
}
main()
{   int n,i,m,j;
    printf("please enter the number of people n:");
  scanf("%d",&n);     
   f(n);
    
    printf("please enter the number m:");
    scanf("%d",&m);
   g(n,m);

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?