freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

面向?qū)ο蟪绦蛟O(shè)計(jì)課程期末復(fù)習(xí)提要-資料下載頁

2025-06-07 22:57本頁面
  

【正文】 鏈表的第一個節(jié)點(diǎn),如果鏈表為空,則head的值為NULL。第二個參數(shù)newData為要插入的新節(jié)點(diǎn)中存放的數(shù)據(jù)。函數(shù)返回值:當(dāng)成功地插入新的節(jié)點(diǎn)時,函數(shù)返回指向新節(jié)點(diǎn)的指針,否則,如果不能申請到內(nèi)存空間,則返回NULL。 Node * AddNode(Node *amp。 head, int newData){ //在下面寫出函數(shù)的實(shí)現(xiàn)} 答案: Node * AddNode(Node * amp。head, int newData) { //申請新的節(jié)點(diǎn)空間 Node * newNode = new Node。 if (newNode == NULL) return NULL。 //填充新節(jié)點(diǎn)的內(nèi)容 newNodedata = newData。 newNodenext = NULL。 //插入到鏈表的結(jié)尾 if (head == NULL) head = newNode。 else { //尋找鏈表的最后一個節(jié)點(diǎn) Node *tail = head。 while(tailnext != NULL) tail = tailnext。 //將新節(jié)點(diǎn)插入到最后 tailnext = newNode。 } return newNode。 } 二、寫一個函數(shù),找出給定字符串中小寫字母字符的個數(shù)。函數(shù)的原型為: int CalcAlpha(char *str)。函數(shù)參數(shù): str為所要處理的字符串;函數(shù)返回值:所給字符串中小寫字母字符的個數(shù) int CalcAlpha(char *str) { //在下面寫上程序的實(shí)現(xiàn) } 答案: int CalcAlpha(char *str) { //判斷字符指針是否為空 if(str == NULL) return 0。 //記錄小寫字母字符個數(shù)的變量 int num=0。 //依次檢查各個字符,如果是小寫字母,則總數(shù)加1 for(int i=0。 str[i]!=0x0。 i++) if(str[i])=39。a39。 amp。amp。 str[i]=39。z39。) num++。 //返回?cái)?shù)字字符個數(shù) return num。 } 三、定義一個日期類Date,該類對象存放一個日期,可以提供的操作有:int GetYear ()。 //取年份int GetMonth ()。 //取月份int GetDay ( )。 //取日子值void SetDate (int year, int month, int day)。 //設(shè)置日期值下面是測試你所定義的日期類的程序: include include “” void main() { Date d1(1999, 1, 14)。 //用所給日期定義一個日期變量 Date d2。 //定義一個具有缺省值的日期,缺省值為1980年1月1日 Date d3(d1)。 //用已有日期x構(gòu)造一個新對象 (1999,3,13)。 cout Date:。 cout () 39。.39。 () 39。.39。 () endl。 cout Date:。 cout () 39。.39。 () 39。.39。 () endl。 cout Date:。 cout () 39。.39。 () 39。.39。 () endl。}要求:(1) 寫出日期類的完整定義,其中,三個Get函數(shù)寫成內(nèi)聯(lián)函數(shù)形式,SetDate寫成非內(nèi)聯(lián)函數(shù)形式。所有數(shù)據(jù)成員都定義為私有成員。注意構(gòu)造函數(shù)的三種形式。(2) 寫出程序的運(yùn)行結(jié)果(3) 修改程序,在日期類中定義日期的輸出函數(shù),這樣,主程序就可以簡化為:void main() { Date d1(1999, 1, 14)。 //用所給日期定義一個日期變量 Date d2。 //定義一個具有缺省值的日期,缺省值為1980年1月1日 Date d3(d1)。 //用已有日期x構(gòu)造一個新對象 (1999,3,13)。 ()。 ()。 ()。}輸出格式和上面一樣。只需要寫出類Date的修改部分。 答案:(1) 類Date的定義://class Date {private: int year,month,day。public: //構(gòu)造函數(shù) Date(int yr, int mth, int dy):year(yr),month(mth),day(dy) {}。 Date():year(1980),month(1),day(1) {}。 Date(Date amp。d1):year(),month(),day() {}。 int GetYear() { return year。} int GetMonth(){ return month。} int GetDay() { return day。} void SetDate(int yr,int mth,int dy)。 }。//void Date::SetDate(int yr,int mth,int dy) { year = yr。 month = mth。 day = dy。}(2) 程序的運(yùn)行結(jié)果Date:Date:Date:(3) 修改部分如下:class Date { …public: void Print()。 …}。void Date::Print(){ cout Date:。 cout year 39。.39。 month 39。.39。 day endl。}16
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)教案相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1