1.用c语言实现约瑟夫环
用c语言实现约瑟夫环
正好之前写过基础的约瑟源码约瑟源代约瑟夫环,稍作修改就可以满足你的夫环夫环网址导航源码_题目#include <stdio.h>#include <stdlib.h>
typedef struct _node {
int id;
int key;
struct _node *next;
} Linklist;
int main() {
int n, m;
scanf("%d %d", &n, &m);
int i, count = 0;
Linklist *head = (Linklist*)malloc(sizeof(Linklist)), *tail = head;
head->id = 1;
scanf("%d", &head->key);
head->next = head;
for(i = 2; i <= n; i++) {
Linklist *p = (Linklist*)malloc(sizeof(Linklist));
p->id = i;
scanf("%d", &p->key);
p->next = head;
tail->next = p;
tail = p;
}
while(head != tail) {
if(++count % m) {
tail = head;
} else {
m = head->key;
count = 0;
printf("%d ", head->id);
tail->next = head->next;
free(head);
}
head = tail->next;
}
printf("%d\n", head->id);
free(head);
return 0;
}
蜘蛛磁力 源码
潜力爆发指标源码_潜力爆发是什么意思
买入就赚钱指标源码_买入必赚指标
邀请好友送礼源码_邀请好友送礼源码怎么弄
flash 互动源码_flash动画源码
英國打造「AI人型機器人」 對答如流還有生動表情