| 网站首页 | 业界新闻 | 群组 | 人才 | 下载频道 | 博客 | 代码贴 | 编程论坛
 雷速体育发帖软件开发QQ118000023 C语言培训|一对一辅导|零基础学编程 LightningChart 快速先进的.Net图表控件

已结贴   问题点数：10  回复次数：7

#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define LEN sizeof(struct student)
struct student
{
int num;
float score;
struct student *next;
};
int n;

int main(void)
{

struct student *creat(void);             //声明建立链表的函数
void print(struct student *);           //声明输出链表的函数
system("pause");
return 0;
}

struct student *creat(void)               //定义建立链表的函数
{
struct student *head = NULL, *p1 = NULL, *p2 = NULL;
p1 = p2 = (struct student *)malloc(LEN);
printf("please input the num : ");
scanf("%d", &(p1 -> num) );
scanf("%f", &(p1 -> score));
n = 0;
while (0 != p1 -> num)
{
n++;
if (1 == n)
{
}
else
{
p2->next = p1;
}
p2 = p1;
p1 = (struct student *)malloc(LEN);
printf("please input the num : ");
scanf("%d", &(p1->num));
scanf("%f", &(p1->score));
}
p2->next = NULL;
}

{
struct student *p;
while (0 != p -> num)
{
printf("成员%d的分数为%f\n", p -> num, p -> score);
p = p->next;
}
}

[ 本帖最后由 firewater 于 2015-3-16 19:09 编辑 ]

得分:0

得分:0

得分:1

{
struct student *p;
while (0 != p )                       //p不等于0， 不是p-> num不等于0
{
printf("成员%d的分数为%f\n", p -> num, p -> score);
p = p->next;
得分:0

得分:0

得分:9

struct student *creat(void)；

得分:0

• 8
• 1/1页
• 1