原创 數據結構 P28-29 算法實現 線性表的鏈式存儲結構——鏈表的查找、插入與刪除

/*鏈表的創建與查找-2.8-插入-2.9-刪除-2.10*/ #include<iostream> using namespace std; struct node {int date;           //數據域node *nex

原创 數據結構 P35 算法實現 雙向循環鏈表的創建

#include<iostream> using namespace std; struct node          //雙向鏈表的節點 {in

原创 數據結構 P31 算法實現 有序鏈表合併爲有序鏈表

/*有序鏈表的合併 —算法2.12*/ #include<iostream> using namespace std; struct node          //創建節點 {int date;node *next; }; class

原创 關於char型賦值給int型

今天在知乎上看到一道關於C++的面試題:    char c=255;    unsigned short b=c;    cout<<b<<endl; 輸出結果爲: 在VC上運行之後得到的輸出爲 65535.   (2^16-1)

原创 C++ 矩陣乘法

只有當矩陣A的列數與矩陣B的行數相等時A×B纔有意義。一個m×n的矩陣a(m,n)左乘一個n×p的矩陣b(n,p),會得到一個m×p的矩陣c(m,p)。 1.一個兩行三列的矩陣和一個三行兩列的矩陣乘法 #include<iostrea

原创 數據結構 P20 算法實現 —A=AUB和歸併排序

/*  例2-1:A=AUB */ #include<iostream> #define ASIZE 5          //宏定義A集合的元素個數 #define BSIZE 6          //宏定義B集合的元素個數 usin

原创 數據結構 P35 算法實現 循環鏈表的創建與查找

#include<iostream> using namespace std; struct node            //創建節點 {int

原创 數據結構 P22-24 算法實現 線性表的插入與刪除

/*線性表的插入*/ #include <iostream> using namespace std; #define LIST_INIT_SIZE     100    //線性表的初始分配量 #define LISTINCREMENT

原创 新手筆記本—C++ 繼承(public、protected、private)構造與析構

訪問權限: public(公有) -內部、 子類、 外部    (客廳- 大家都能參觀)                                   最高級 protected(保護)-   內部 、子類     (臥室-只有你和

原创 數據結構 P30 算法實現 鏈表的頭插法 尾插法

/*鏈表的正向建立—頭插法 & 鏈表的逆向建立—尾插法 算法2.11*/ #include<iostream> #define OK 1 #define  ERROR 0 int a,b; using namespace std;  s

原创 數據結構 p25-26 算法實現 線性表的查找與歸併排序2

/*線性表的查找 2.6*/ #include <iostream> using namespace std; #define SIZE  6 int main() {int a[SIZE]={9,2,8,4,5,6};int elem

原创 數據結構 P16 算法實現

/*  語句++x的執行次數關於n的增長率爲n^2,它是語句頻度表達式(n-1)*(n-2)/2中增長最快的項  */ #include<iostream> using namespace std; #define n 5 int ma

原创 筆記本

bool型變量 若給bool型變量賦予一個0/1的值,它會正常儲存0/1,但若給它賦予一個非0非1的值,它將會保存出錯(隨機保存一個數)並輸出真值。 C++ 結構體裏可以包含函數,而C裏面不可以。 Struct point { int

原创 代碼筆記-C++ 繼承

#include<iostream> using namespace std; class A { public:     A(){cout<<"A

原创 PAT-1031.查驗身份證(15)

#include<iostream> #include<string> using namespace std; int main() {int N,i,j=0,k=0,B[17]={7,9,10,5,8