约瑟夫环c语言代码加注释,约瑟夫环c语言代码原创.doc

约瑟夫环c语言代码原创

#include

#include

struct peolist int n;

int secret;

struct peolist *next;

;

struct outlist int num;

struct outlist *next;

;

struct peolist *creat1 int i 1;

struct peolist *head;

struct peolist *p1,*p2;

printf "依次输入个人的密码,输入非正数时结束\n" ;

p1 p2 struct peolist * malloc sizeof struct peolist ;

scanf "%d",&p1- secret ;

head p1;

p1- n i;

while p1- secret 0 i++;

p2 p1;

p1 struct peolist * malloc sizeof struct peolist ;

scanf "%d",&p1- secret ;

p1- n i;

p2- next p1; p2- next head;

return head; struct outlist *creat2 struct peolist *head int i,m;

struct peolist *p0,*temp;

struct outlist *head1;

struct outlist *p1,*p2;

printf "输入初始m值\n" ;

scanf "%d",&m ;

p1 p2 struct outlist * malloc sizeof struct outlist ;

head1 p1;

p0 head;temp NULL;

while p0- next! p0 i 1;

while i m if i+1 m temp p0; p0 p0- next; i++; p1- num p0- n;

m p0- secret;

p0 p0- next;

temp- next p0;

p2 p1;

p1 struct outlist * malloc sizeof struct outlist ;

p2- next p1; p2 p1;

p2- num p0- n;

p2- next NULL;

return head1; void main struct peolist *head1;

struct outlist *head2,*p;

head1 NULL;head2 NULL;p NULL;

head1 creat1 ;

head2 creat2 head1 ;

p head2;

while p! NULL printf "%d ",p- num ;

p p- next;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值