打印
[国产单片机]

我写错了的C语言作业,谁能帮我改改吗!

[复制链接]
628|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
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

粉丝