第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

數(shù)據(jù)結(jié)構(gòu)萌新的問(wèn)題

數(shù)據(jù)結(jié)構(gòu)萌新的問(wèn)題

C
南梟 2018-09-05 10:39:17
数据结构老师在给我们复习C语言时布置了一个实验,内容如图,由于没有学习过这一内容,故向大家请教。
查看完整描述

1 回答

已采納
?
AAnonymous

TA貢獻(xiàn)62條經(jīng)驗(yàn) 獲得超31個(gè)贊

這是個(gè)鏈表

#include?<cstdio>

struct?StudentNode?{
????char?name[10];
????int?rank;
????int?score;
????StudentNode?*pNext;
????StudentNode()?:?name(""),?rank(0),?score(0),?pNext(nullptr)?{}
};

struct?StudentLinkList?{
????StudentNode?*pHead;
????StudentLinkList()?:?pHead(new?StudentNode)?{?}
????~StudentLinkList()?{
????????StudentNode?*node?=?pHead;
????????while?(node?!=?nullptr)?{
????????????StudentNode?*tmp?=?node->pNext;
????????????delete?node;
????????????node?=?tmp;
????????}
????}
????void?createLinkList(int?n)?{
????????printf("creating?linklist?with?%d?nodes\n",?n);
????????StudentNode?*node?=?pHead;
????????StudentNode?*tmp;
????????for?(auto?i?=?1;?i?<=?n;?++i)?{
????????????tmp?=?new?StudentNode;
????????????printf("??>>?input?%dst?node's?infos:?name,?rank,?score:?",?i);
????????????scanf("%s%d%d",?tmp->name,?&(tmp->rank),?&(tmp->score));
????????????node->pNext?=?tmp;
????????????node?=?tmp;
????????????tmp?=?nullptr;
????????}
????????printf("linklist?created\n\n");
????}

????void?showLinkList()?{
????????printf("display?all?elements?of?linklist\n??>>?");
????????StudentNode?*node?=?pHead;
????????while?(node->pNext?!=?nullptr)?{
????????????printf("|?%s?|?%d?|?%d?|?-->?",?node->pNext->name,?node->pNext->rank,?node->pNext->score);
????????????node?=?node->pNext;
????????}
????????printf("null\n\n");
????}
};

int?main()?{
????StudentLinkList?linkList;
????linkList.createLinkList(3);
????linkList.showLinkList();
}

C:\Users\xxx\CLionProjects\Test\cmake-build-debug\Test.exe

creating linklist with 3 nodes

? >> input 1st node's infos: name, rank, score: WANG 1 65

? >> input 2st node's infos: name, rank, score: ZHANG 2 98

? >> input 3st node's infos: name, rank, score: LI 3 85

linklist created


display all elements of linklist

? >> | WANG | 1 | 65 | --> | ZHANG | 2 | 98 | --> | LI | 3 | 85 | --> null



Process finished with exit code 0


查看完整回答
1 反對(duì) 回復(fù) 2018-09-06
  • 1 回答
  • 0 關(guān)注
  • 766 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)