編程題(15_01.c)
結(jié)構(gòu)
struct student
{
long num
char name[20]
int score
struct student *next
}
鏈表練習(xí):
(1).編寫函數(shù)struct student * creat(int n),創(chuàng)建一個按學(xué)號升序排列的新鏈表,每個鏈表中的結(jié)點中
的學(xué)號、成績由鍵盤輸入,一共n個節(jié)點。
(2).編寫函數(shù)void print(struct student *head),輸出鏈表,格式每行一個結(jié)點,包括學(xué)號,姓名,分數(shù)。
(3).編寫函數(shù)struct student * merge(struct student *a,struct student *b), 將已知的a,b兩個鏈表
按學(xué)號升序合并,若學(xué)號相同則保留成績高的結(jié)點。
(4).編寫函數(shù)struct student * del(struct student *a,struct student *b),從a鏈表中刪除b鏈表中有
相同學(xué)號的那些結(jié)點。
(5).編寫main函數(shù),調(diào)用函數(shù)creat建立2個鏈表a,b,用print輸出倆個鏈表;調(diào)用函數(shù)merge升序合并2個
鏈表,并輸出結(jié)果;調(diào)用函數(shù)del實現(xiàn)a-b,并輸出結(jié)果。
a:
20304,xxxx,75,
20311,yyyy,89
20303,zzzz,62
20307,aaaa,87
20320,bbbb,79
b:
20302,dddd,65
20301,cccc,99
20311,yyyy,87
20323,kkkk,88
20307,aaaa,92
20322,pppp,83
標簽:
student
struct
score
long
上傳時間:
2016-04-13
上傳用戶:zxc23456789
對PL0原編譯器進行了以下的擴充:1.增加以下保留字else(elsesym), for(forsym),to(tosym),downto(downtosym),return(returnsym),[(lmparen),](rmparen)
2.增加了以下的運算符:+=(eplus),-=(eminus),++(dplus),--(dminus)
取址運算符&(radsym),指向運算符@(padsym)
3.修改單詞:修改不等號#為<>
4.擴充語句:(1)增加了else子句
(2)增加了for語句
5.增加運算:(1).++運算 (2).--運算;(3).+=運算 (4).-=運算;(5).&取址運算;
(6).@指向運算;
6.增加類型:(1).增加多維數(shù)組a[i1][i2][i3]……[i(n-1)][i(n-2)][in] (2).增加指針類型(任何變量都能存放指針,但不支持指針的指針,如b:=@@a應(yīng)該改寫為c:=@a,b:=@c)
7.將過程procedure擴展為函數(shù):(1).允許定義過程時在其后加參數(shù)(var a, var b,……..,var n) (2)允許通過指針向函數(shù)形式參數(shù)傳地址;(3)允許返回值;可以用 a:=p(a,b,c….,n) 返回
標簽:
downtosym
returnsym
elsesym
downto
上傳時間:
2016-07-02
上傳用戶:saharawalker