Circular list example -- Josephus problem
来源:互联网 发布:个性淘宝女装店名 编辑:程序博客网 时间:2024/04/29 22:14
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct node* link;
- struct node
- {
- int item;
- link next;
- };
- int main( int argc, char *argv[] )
- {
- int i, N = atoi( argv[1] ), M = atoi( argv[2] );
- link t = malloc( sizeof *t ), x = t;
- t->item = 1;
- t->next = t;
- for ( i = 2; i <= N; i++ )
- {
- x = ( x->next = malloc( sizeof *t ) );
- 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;
- }
- Circular list example -- Josephus problem
- Circular linked list and Josephus ring
- Josephus problem
- josephus problem
- Josephus problem
- Josephus Problem
- Josephus Problem
- Josephus problem
- Josephus Problem
- josephus list
- The Josephus Problem
- The Josephus Problem
- 【算法实现】josephus problem
- 约瑟夫问题(Josephus problem)
- Josephus problem(约瑟夫问题)
- TOJ 10006 Josephus Problem
- Josephus problem solution
- CareerCup Josephus Problem
- jBPM-jPDL学习笔记—框架设计简介(六)
- Oracle 数据字典视图(V$,GV$,X$)
- ORACLE学习笔记--性能优化
- [转]秀下我的瓦伦西亚
- ORACLE表空间恢复方案
- Circular list example -- Josephus problem
- Oracle:由临时表空间
- 平时留意的一些短句【不断增加中】
- 关于子线程的进度条
- 算法题目1——闭合篱笆
- linux2.6.11启动代码之bootsect.s
- 中文乱码
- ORA-01653: unable to extend table string.string by string in tablespace string
- VB Timer时钟的准确性