国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

電子商務(wù)網(wǎng)站開發(fā)平臺圖目前較好的crm系統(tǒng)

電子商務(wù)網(wǎng)站開發(fā)平臺圖,目前較好的crm系統(tǒng),短視頻拍攝策劃方案,網(wǎng)站建設(shè)免費軟件Description 用C語言和類實現(xiàn)單鏈表&#xff0c;含頭結(jié)點 屬性包括&#xff1a;data數(shù)據(jù)域、next指針域 操作包括&#xff1a;插入、刪除、查找 注意&#xff1a;單鏈表不是數(shù)組&#xff0c;所以位置從1開始對應(yīng)首結(jié)點&#xff0c;頭結(jié)點不放數(shù)據(jù) 類定義參考 #include<…

Description

用C++語言和類實現(xiàn)單鏈表,含頭結(jié)點

屬性包括:data數(shù)據(jù)域、next指針域

操作包括:插入、刪除、查找

注意:單鏈表不是數(shù)組,所以位置從1開始對應(yīng)首結(jié)點,頭結(jié)點不放數(shù)據(jù)

類定義參考

#include<iostream>
using namespace std;
#define ok 0
#define error -1// 鏈表結(jié)點定義
class ListNode
{
public:int data;ListNode *next;ListNode() {next = NULL;}
};
// 帶頭結(jié)點的單鏈表類定義
class LinkList
{
public:ListNode *head;int len;// 操作定義LinkList();~LinkList();ListNode *LL_index(int i);      // 返回第i個結(jié)點的指針,如果不存在返回NULLint LL_get(int i);              // 獲取第i個元素的數(shù)據(jù)int LL_insert(int i, int item); // 把數(shù)值item插入第i個位置int LL_del(int i);              // 刪除第i個結(jié)點void LL_display();              // 輸出單鏈表的內(nèi)容
};
LinkList::LinkList()
{head = new ListNode();len = 0;
}
LinkList::~LinkList()
{ListNode *p, *q;p = head;while(p != NULL){q = p;p = p->next;delete q;}len = 0;head = NULL;
}
void LinkList::LL_display()
{ListNode *p;p = head->next;while(p){cout << p->data << ' ';p = p->next;}cout << endl;
}

Input

  • 第1行先輸入n表示有n個數(shù)據(jù),接著輸入n個數(shù)據(jù)
  • 第2行輸入要插入的位置和新數(shù)據(jù)
  • 第3行輸入要插入的位置和新數(shù)據(jù)
  • 第4行輸入要刪除的位置
  • 第5行輸入要刪除的位置
  • 第6行輸入要查找的位置
  • 第7行輸入要查找的位置

Output

數(shù)據(jù)之間用空格隔開,

第1行輸出創(chuàng)建后的單鏈表的數(shù)據(jù)

每成功執(zhí)行一次操作(插入或刪除),輸出執(zhí)行后的單鏈表數(shù)據(jù)

每成功執(zhí)行一次查找,輸出查找到的數(shù)據(jù)

如果執(zhí)行操作失敗(包括插入、刪除、查找等失敗),輸出字符串error,不必輸出單鏈表

Sample

?

?AC代碼:

#include<iostream>
using namespace std;
#define ok 0
#define error -1// 鏈表結(jié)點定義
class ListNode
{
public:int data;ListNode* next;ListNode() { next = NULL; }
};
// 帶頭結(jié)點的單鏈表類定義
class LinkList
{
public:ListNode* head;int len;// 操作定義LinkList();ListNode* LL_index(int i) {};      // 返回第i個結(jié)點的指針,如果不存在返回NULLvoid LL_get(int i) {if (i <= 0 || i > len ) {cout << "error" << endl;}else {ListNode* p;p = head;for (int j = 0; j < i; j++) {p = p->next;}cout << p->data << endl;}};              // 獲取第i個元素的數(shù)據(jù)void LL_insert(int i, int item) {if (i <= 0 || i > len + 1) {cout << "error" << endl;}else {ListNode* p;p = head;for (int j = 1; j < i; j++) {p = p->next;}ListNode* s = new ListNode;s->data = item;s->next = p->next;p->next = s;p = s;len++;LL_display();}}; // 把數(shù)值item插入第i個位置void LL_del(int i) {if (i <= 0 || i > len) {cout << "error" << endl;}else {ListNode* p;p = head;for (int j = 1; j < i; j++) {p = p->next;}p->next = p->next->next;LL_display();len--;}};              // 刪除第i個結(jié)點void LL_display();              // 輸出單鏈表的內(nèi)容
};
LinkList::LinkList()
{head = new ListNode();len = 0;
}
void LinkList::LL_display()
{ListNode* p;p = head->next;while (p){cout << p->data << ' ';p = p->next;}cout << endl;
}int main() {int t;int data;cin >> t;LinkList L;ListNode* p;p = L.head;while (t--) {ListNode* s = new ListNode;L.len++;cin >> data;s->data = data;s->next = p->next;p->next = s;p = p->next;}L.LL_display();int i, item;cin >> i >> item;L.LL_insert(i, item);cin >> i >> item;L.LL_insert(i, item);cin >> i;L.LL_del(i);cin >> i;L.LL_del(i);cin >> i;L.LL_get(i);cin >> i;L.LL_get(i);
}

http://m.aloenet.com.cn/news/33260.html

相關(guān)文章:

  • 網(wǎng)站開發(fā)有哪些職位中國十大流量網(wǎng)站
  • 哪些企業(yè)合適做網(wǎng)站核心關(guān)鍵詞舉例
  • 網(wǎng)站外鏈建設(shè)可以提升網(wǎng)站權(quán)重嗎網(wǎng)絡(luò)市場營銷策劃書
  • 網(wǎng)站域名hk南京百度推廣優(yōu)化排名
  • 自己設(shè)計一個網(wǎng)頁優(yōu)化關(guān)鍵詞的方法有哪些
  • 做網(wǎng)站設(shè)計需要什么軟件深圳在線制作網(wǎng)站
  • 楊浦做網(wǎng)站百度客服人工電話多少
  • 如何申請做網(wǎng)站編輯呢互聯(lián)網(wǎng)推廣怎么找客戶
  • brackets做的網(wǎng)站阿里巴巴官網(wǎng)首頁
  • 做網(wǎng)站能設(shè)置關(guān)鍵詞在百度中搜索到百度站長收錄入口
  • 手機(jī)web服務(wù)器西安搜索引擎優(yōu)化
  • 網(wǎng)站建站圖片網(wǎng)站流量排行
  • 炒域名 網(wǎng)站nba最新新聞新浪
  • 移動端下載百度搜索推廣優(yōu)化師工作內(nèi)容
  • 網(wǎng)站建設(shè)制作汕頭北京seo網(wǎng)站優(yōu)化培訓(xùn)
  • linux wordpress南京百度提升優(yōu)化
  • 做網(wǎng)站得花多少錢搜索引擎優(yōu)化包括
  • 課桌公司網(wǎng)站建設(shè)百度seo搜索引擎優(yōu)化
  • 前段模板的網(wǎng)站企業(yè)培訓(xùn)機(jī)構(gòu)
  • 攝影設(shè)計網(wǎng)站百度知道官網(wǎng)登錄入口
  • 做網(wǎng)站需注意事項湛江今日頭條新聞
  • 做彩妝網(wǎng)站的公司建站教程
  • 網(wǎng)站建設(shè)的招聘要求張家口網(wǎng)站seo
  • 什么軟件 做短視頻網(wǎng)站好北京百度推廣優(yōu)化排名
  • 高德地圖有外資背景嗎seo優(yōu)化技術(shù)廠家
  • 網(wǎng)站建設(shè)制作公司哪家打開百度網(wǎng)頁
  • 如何建立一個網(wǎng)站根目錄山東企業(yè)網(wǎng)站建設(shè)
  • 848給我做一下88網(wǎng)站人工智能培訓(xùn)機(jī)構(gòu)哪個好
  • 蘇州招聘網(wǎng)站建設(shè)bt磁力搜索
  • 在線做抽獎網(wǎng)站營銷的四種方式