星期天的噩夢初中優秀作文400字
#include “stdafx.h”

typedef char eleType; /pic/p>
typedef struct listnode { /pic/p>
eleType data;
struct listnode *next;
}node;
node *create(int n) { /pic/p>
node *p = (node *)malloc(sizeof(node));
node *head = p; head->data = ‘A’;
for(int i=’B'; i<’A'+n; i++) {
p = (p->next = (node *)malloc(sizeof(node)));
p->data = i;
p->next = NULL;
}
return head;
}
void addCircle(node *head, int n) { /pic/p>
node *q, *p = head;
for(int i=1; p->next; i++) {
if(i==n) q = p;
p = p->next;
}
p->next = q;
}
int isCircle(node *head) { /pic/p>
node *p=head,*q=head;
while( p->next && q->next) {
p = p->next;
if (NULL == (q=q->next->next)) return 0;
if (p == q) return 1;
}
return 0;
}
int main(int argc, char* argv[]) {
node *head = create(12);
addCircle(head, 8); /pic/p>
printf(“%d\n”, isCircle(head));
}
【星期天的噩夢初中優秀作文400字】相關文章:
那個星期天作文優秀初中(精選48篇)12-02
清晨“噩夢”05-13
星期天初中作文02-10
(優秀)星期天的作文01-16
星期天作文[優秀]12-18
星期天的作文(優秀)12-30
星期天的作文[優秀]09-28
星期天的作文【優秀】01-06
(優秀)星期天的作文01-08
快樂星期天初中作文02-16
- 相關推薦