标题:猴子大王,然我哭了无数遍
取消只看楼主
编程的未来
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-3-21
结帖率:0
已结贴  问题点数:10 回复次数:1 
猴子大王,然我哭了无数遍
现在改成这样,刚才的我已经完全没办法,不会搞了。。但是最后的结果很不对
#include<stdio.h>
 #include<malloc.h>
 #define MONKEY_NUMBER 50

 typedef int datatype;
 typedef struct node
 {
     datatype number;
     struct node *next;
 }Linklist;
 Linklist *head,*s,*t,*r;
 Linklist *p;

 int main()
 {
     void Sign_number(Linklist *,Linklist*,Linklist*);
     void Circulate_main(Linklist *,Linklist*,Linklist*);
     t = (Linklist*)malloc(sizeof(Linklist));
     head = t;
     s = (Linklist*)malloc(sizeof(Linklist));

     Sign_number(head,s,t);
     Circulate_main(head,s,t);
     return 0;
 }

 void Sign_number(Linklist *head,Linklist *s,Linklist *t)
 {
     int i,j,k;
     for(i = 0;i < MONKEY_NUMBER;i++)
     {
         s = (Linklist*)malloc(sizeof(Linklist));
         s->number = i + 1;
         t->next = s;
         t = s;

     }

     s->next = head->next;

     s = head->next;
     for(j = 0;j < 50;j++)
     {
         printf("%2d ",s->number);
         s = s->next;
     }

 }

 void Circulate_main(Linklist *head,Linklist *s,Linklist *t)
 {
     int i,j,k;
     s = head->next;
     while(s->next != s)
     {
         for(i = 0;i < 3;i++)
         {
             t = s;
             s = s->next;
            
            
         }
         t->next = s->next;
         printf("%2d",s->number);
         free(s);
         s = t->next;   
     }
     printf("%2d",s->number);
     getchar();
     getchar();
 }
搜索更多相关主题的帖子: head void include number 
2013-03-31 23:29
编程的未来
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-3-21
得分:0 
回复 4楼 不玩虚的
........估计 是算法出错了
2013-04-01 13:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-402561-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.900224 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved