?? ch10_11.cpp
字號:
//***********************
//** ch10_11.cpp **
//***********************
#include <iostream.h>
struct Student
{
long number;
float score;
Student* next;
};
Student* head; //鏈首指針
Student* Create()
{
Student* pS; //創建的結點指針
Student* pEnd; //鏈尾指針,用于在其后面插入結點
pS=new Student; //新建一個結點,準備插入鏈表
cin >>pS->number >>pS->score; //給結點賦值
head=NULL; //一開始鏈表為空
pEnd=pS;
while(pS->number!=0){
if(head==NULL)
head=pS;
else
pEnd->next=pS;
pEnd=pS; //s點
pS=new Student;
cin >>pS->number >>pS->score;
}
pEnd->next=NULL;
delete pS;
return(head);
}
void ShowList(Student* head)
{
cout <<"now the items of list are \n";
while(head){
cout <<head->number <<"," <<head->score <<endl;
head=head->next;
}
}
void main()
{
ShowList(Create());
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -