> 文章列表 > C语言源程序是什么(源程序是什么)

C语言源程序是什么(源程序是什么)

C语言源程序是什么(源程序是什么)

关于C语言源程序是什么,源程序是什么这个很多人还不知道,今天小六来为大家解答以上的问题,现在让我们一起来看看吧!

1、#include\"stdio.h\"#include\"malloc.h\"#define LEN sizeof(struct student)struct student{long int num;float score;struct student *next;};struct student *creat(void){struct student *head;struct student *p1,*p2;int n=0;p2=p1=(struct student*)malloc(LEN);printf(\"请输入学号和成绩: \");scanf(\"%ld%f\",&p1->num,&p1->score);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);printf(\"请输入学号和成绩: \");scanf(\"%ld%f\",&p1->num,&p1->score);}p2->next=NULL;return(head);}void main(){struct student a,b,c;struct student *head,*p,*result;a.num=99101;a.score=89.5;b.num=99103;b.score=90;c.num=99107;c.score=85;head=&a;a.next=&b;b.next=&c;c.next=NULL;p=head;do{printf(\"%ld%5.lf\",p->num,p->score);p=p->next;}while(p!=NULL);result = creat();do{printf(\"%ld%5.lf\",result->num,result->score);result=result->next;}while(result!=NULL);}。

本文到此分享完毕,希望对大家有所帮助。