* (程式頭部注釋開始)
* 程式的版權和版本宣告部分
* 檔名稱:建立專門的鍊錶類處理有關動態鍊錶的操作
* 作 者: 齊豔紅
* 完成日期: 2012 年 05 月 24 日
* 版 本 號:
* 對任務及求解方法的描述部分
* 輸入描述:
* 問題描述:動態鍊錶也是程式設計中的一種非常有用的資料結構。
* 程式頭部的注釋結束
*/[cpp] view plaincopyprint?
#includeusing namespace std;
class student
student *next;
int num;
double score;
};
class mylist
mylist(int n,double s) //以student(n,s)作為單結點的鍊錶
int display(); //輸出鍊錶,返回值為鍊錶中的結點數
void insert(int n,double s); //插入:將student(n,s)結點插入鍊錶,該結點作為第乙個結點
void cat(mylist &il); //將鍊錶il連線到當前物件的後面
int length(); //返回鍊錶中的結點數
private:
student *head;
};
void mylist::insert(int n,double s) //插入:將student(n,s)結點插入鍊錶,該結點作為第乙個結點
ss->next=new student(n,s);
} void mylist::cat(mylist &il) //將鍊錶il連線到當前物件的後面
ss->next=il.head;
} int mylist::length() //返回鍊錶中的結點數
return length;
} int mylist::display() //輸出鍊錶,返回值為鍊錶中的結點數
return length;
} int main()
cout<<"head1: "
mylist head2(1001,98.4); //建立head2鍊錶
cout<<"head2: "
head2.cat(head1); //反head1追加到head2後面
cout<<"length of head2 after cat: "
system("pause");
return 0;
}
第十四周任務(二)
建立自己的鍊錶 includeusing namespace std class student student next int num double score class mylist mylist int n,double s 以student n,s 作為單結點的鍊錶 int displa...
第十四周 任務一
程式頭部注釋開始 程式的版權和版本宣告部分 檔名稱 建立專門的陣列類處理有關陣列的操作 作 者 薛廣晨 完成日期 2012 年 05 月18 日 版 本 號 x1.0 對任務及求解方法的描述部分 輸入描述 問題描述 陣列是幾乎所支援的組織資料的方法。c和c 對陣列型別提供了內建支援,使我們利用陣列實...
第十四周專案二
檔名稱 jcy 作 者 賈存鈺 完成日期 2017年12月7日 問題描述 已知乙個關鍵字序列為if while for case do break else struct union int double float char long bool,共15個字串,雜湊函式h key 為關鍵字的第乙個字...