猴子吃桃子问题的程序这个程序哪里有问题?可以运行,但是得不出正确结果1534来,怎么回事啊这个...#include "stdio.h"#include "stdlib.h"#define NULL 0typedef struct linknode{int data;struct linknode*next; }node;node*hea
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/03 12:18:32
![猴子吃桃子问题的程序这个程序哪里有问题?可以运行,但是得不出正确结果1534来,怎么回事啊这个...#include](/uploads/image/z/4387693-13-3.jpg?t=%E7%8C%B4%E5%AD%90%E5%90%83%E6%A1%83%E5%AD%90%E9%97%AE%E9%A2%98%E7%9A%84%E7%A8%8B%E5%BA%8F%E8%BF%99%E4%B8%AA%E7%A8%8B%E5%BA%8F%E5%93%AA%E9%87%8C%E6%9C%89%E9%97%AE%E9%A2%98%3F%E5%8F%AF%E4%BB%A5%E8%BF%90%E8%A1%8C%2C%E4%BD%86%E6%98%AF%E5%BE%97%E4%B8%8D%E5%87%BA%E6%AD%A3%E7%A1%AE%E7%BB%93%E6%9E%9C1534%E6%9D%A5%2C%E6%80%8E%E4%B9%88%E5%9B%9E%E4%BA%8B%E5%95%8A%E8%BF%99%E4%B8%AA...%23include+%22stdio.h%22%23include+%22stdlib.h%22%23define+NULL+0typedef+struct+linknode%7Bint+data%3Bstruct+linknode%2Anext%3B+%7Dnode%3Bnode%2Ahea)
猴子吃桃子问题的程序这个程序哪里有问题?可以运行,但是得不出正确结果1534来,怎么回事啊这个...#include "stdio.h"#include "stdlib.h"#define NULL 0typedef struct linknode{int data;struct linknode*next; }node;node*hea
猴子吃桃子问题的程序
这个程序哪里有问题?可以运行,但是得不出正确结果1534来,怎么回事啊这个...
#include "stdio.h"
#include "stdlib.h"
#define NULL 0
typedef struct linknode
{
int data;
struct linknode*next;
}node;
node*head;
void creat()
{
node*p,*s;
int peaches=1;
int day=10;
head=(node*)malloc(sizeof(node));
p=head;
while(day>=1)
{
s=(node*)malloc(sizeof(node));
s->data=peaches;
p->next=s;
p=s;
peaches=(peaches+1)*2;
day;
}
p->next=NULL;
p=head;
head=head->next;
free(p);
}
void print()
{
int day=10;
node*p;
p=head;
while(p&&day>=1)
{
printf("第%d天的桃子数:%d个",day,p->data);
p=p->next;
day;
}
}
void main()
{
creat();
print();
}
猴子吃桃子问题的程序这个程序哪里有问题?可以运行,但是得不出正确结果1534来,怎么回事啊这个...#include "stdio.h"#include "stdlib.h"#define NULL 0typedef struct linknode{int data;struct linknode*next; }node;node*hea
10