为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > 数据结构约瑟夫环

数据结构约瑟夫环

2017-10-06 3页 doc 13KB 9阅读

用户头像

is_337177

暂无简介

举报
数据结构约瑟夫环数据结构约瑟夫环 #include #include struct Lnode //创建链表 { int number; int password; struct Lnode *next; }Lnode,*p,*q,*head; int main(void) { int n,i,m,j; printf("Please enter the number of people n:"); scanf("%d",&n); for(i=1;inext=q; p=q; } printf("Please e...
数据结构约瑟夫环
数据结构约瑟夫环 #include #include struct Lnode //创建链 { int number; int password; struct Lnode *next; }Lnode,*p,*q,*head; int main(void) { int n,i,m,j; printf("Please enter the number of people n:"); scanf("%d",&n); for(i=1;i<=n;i++) { if(i==1) { head=p=(struct Lnode *)malloc(sizeof(Lnode)); } else { q=(struct Lnode *)malloc(sizeof(Lnode)); 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; printf("Please enter the number m: "); scanf("%d",&m); printf("The result is:\n"); for(j=1;j<=n;j++) { for(i=1;inext) ; m=p->password; printf("%d ",p->number); p->number=p->next->number; //删除报m的节点 p->password=p->next->password; q=p->next; p->next=p->next->next; free(q); } printf("\n"); return(0); }
/
本文档为【数据结构约瑟夫环】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索