源程序是什么 源程序是用計算機語言編寫的程序


源程序是什么 源程序是用計算機語言編寫的程序

文章插圖
大家好,小跳來為大家解答以上的問題 。源程序是用計算機語言編寫的程序,源程序是什么這個很多人還不知道,現在讓我們一起來看看吧!
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);} 。
【源程序是什么 源程序是用計算機語言編寫的程序】本文到此分享完畢 , 希望對大家有所幫助 。