//_十分感谢_
#include<stdio.h>
#include<stdlib.h>
typedef struct Elemtype
{
int num[20];
int sum[10];
float score;
}Elemtype;
typedef struct Node
{
Elemtype Data;
struct Node* next;
}Node,* LinkList;
LinkList creatList_head(LinkList L) //_头插法_
{
LinkList s;
L=(Node*)malloc(sizeof(Node));
L->next=NULL;
int flag=1;
while(flag)
{
s=(Node*)malloc(sizeof(Node));
printf("\n请输入姓名,学号,成绩\n");
scanf("%c",&(s->Data.num[20]));
scanf("%c",&(s->Data.sum[20]));
scanf("%3.1f",&(s->Data.score));
s->next=L->next;
L->next=s;
printf("是否继续录入:输入1继续,0结束");
scanf("%d",&flag);
}
return L;
}
void printList(LinkList L) //_输出_
{
LinkList p;
p=L->next;
while(p!=NULL)
{
printf("%d",p->Data.num);
printf("%d",p->Data.sum);
printf("%d",p->Data.score);
printf("\n");
p=p->next;
}
}
int main()
{
LinkList L;
printf("请输入信息!");
L=creatList_head(L);
printList(L);
return 0;
}
刚学的c语言,能帮我看下那里有问题吗
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- CSDN专家-link 2021-09-24 11:37关注
把next定义前的struct去掉吧
typedef struct Node { Elemtype Data; struct Node* next; }Node,* LinkList;
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用