[国产单片机] 我写错了的C语言作业,谁能帮我改改吗!

[复制链接]
 楼主| Kayla9 发表于 2016-6-11 22:15 | 显示全部楼层 |阅读模式
#include<stdio.h>
#include<malloc.h>
#define LEN sizeof(struct Student)
struct Student
    {
   long num;
   float score;
   struct Student*next;
    } ;
int n;
struct Student*creat()
{
struct Student*head;
struct Student*p1,*p2;
n=0;
p1=p2=(struct Student*)malloc(LEN);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct Student*)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}
void print(struct Student head)
{ struct Student*p;
printf("\nNow,These %d records are:\n",n);
p=head;
if(head!=NULL)
do
{
printf("%ld%5.1f\n",p->num,p->score);
p=p->next;
} while(p!=NULL);
}
void main()
{
struct Student*head;
head=creat();
print(head);
}
刃影 发表于 2016-6-15 13:18 | 显示全部楼层
你能写清楚你编程要求和注释吗?这样看起来一头雾水
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

18

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部

5

主题

18

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部