Time of Update: 2018-12-05
一、文字檔與二進位檔案的定義 大家都知道電腦的儲存在物理上是二進位的,所以文字檔與二進位檔案的區別並不是物理上的,而是邏輯上的。這兩者只是在編碼層次上有差異。 簡單來說,文字檔是基於字元編碼的檔案,常見的編碼有ASCII編碼,UNICODE編碼等等。二進位檔案是基於值編碼的檔案,你可以根據具體應用,指定某個值是什麼意思(這樣一個過程,可以看作是自訂編碼)。
Time of Update: 2018-12-05
下面代碼因為T2沒有實現T2(T1)複製建構函式,所以編譯錯誤g++報錯:test.cpp|23 col 25| 錯誤: 對‘T2::T2(T1&)’的調用沒有匹配的函數 #include <vector>#include<stdio.h>#include <string.h>#include<iostream>#include <string>using namespace std;class T1{public:int a;
Time of Update: 2018-12-05
先看昨天的成果:勉強衝進前50.今天花點時間做一些ACM的水題。1.菲波那且數列菲波那契(Fibonacci)數(簡稱菲氏數)定義為: ⎧ f (0) = 0 ⎪ ⎨ f (1) = 1 ⎪ f (n) = f (n − 1) + f (n − 2) (n > 1且n ∈ 整數) ⎩ 如果寫出菲氏數列,則應該是: 0 1 1 2 3 5 8 13 21 34 ... 如果求其第 6 項,則應為 8。 求第 n 項菲氏數。 輸入描述:輸入資料含有不多於 50 個的正整數 n(0≤n≤46)。
Time of Update: 2018-12-05
1、對於虛擬函數,子類裡的成員存取權限符可以和父類不同。即對於基類的函數func如果是public的,子類中它可以是private的。 class Base {public:Base();virtual ~Base();public:virtual void func(void); // 公有};class Derived : public Base {public:Derived();virtual ~Derived();private:void func(void); //
Time of Update: 2018-12-05
#include <stdio.h>;#include <sys/types.h>;#include <sys/socket.h>;#include <sys/ioctl.h>;#include <netinet/in.h>;#include <net/if.h>;#include <net/if_arp.h>;#include <arpa/inet.h>;#include
Time of Update: 2018-12-05
文章目錄 數組實現參數傳值實現引用實現全域變數實現另一種數組實現 棧的C語言實現簡述棧是實現後進先出(FIFO)策略的一種基本資料結構。我們可以通過多種方式實現棧這種資料結構。我們可以用下面的結構體來定義棧:typedef struct stack { inttop; intkey[M];}
Time of Update: 2018-12-05
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <assert.h>#define LIST_DATA_FILENAME"list.data"//--------------------------------------------------------------------// Type definition//
Time of Update: 2018-12-05
在C++中,我們經常遇到需要對一個對象數組進行複製,比如下面一個結構: struct STest{ int a; int b; vector<int> vctInt;}; 我們定義了兩個數組:STest A[20];STest B[20];需要將數組A中的所有內容複寫到B數組中,通常我們的做法都是這樣: for(size_t i = 0; i < ARRAYSIZE(A); ++i){ A[i] =
Time of Update: 2018-12-05
template< class Base, int TYPE_ID >class GetClassEx: public Base{public:GetClassEx(const long _ID):ID(_ID){}//擷取效果類型virtual long GetType(){ return TYPE_ID; }//擷取效果IDvirtual long GetEffectID(){ return ID; }private:const long ID;}; template<
Time of Update: 2018-12-05
1.比較字串 private void button1_Click(object sender, EventArgs e) { if(string.Compare(textBox1 .Text .ToLower (),textBox2.Text.ToLower())<0) MessageBox.Show ("字串1小於字串2","資訊",MessageBoxButtons.OK,MessageBoxIcon.Information
Time of Update: 2018-12-05
/*Description輸入n值,並利用格裡高裡公式計算並輸出圓周率: Input輸入公式中的n值。 Output輸出圓周率,保留5位小數。 Sample Input1Sample Output2.66667*/#include <iostream>#include <iomanip>using namespace std;int main(){int n;double sum=0;double pi;cin>>n;for(int
Time of Update: 2018-12-05
本文原始地址:C演算法學習筆記(2)-二叉尋找樹尋找操作若根結點的關鍵字值等於尋找的關鍵字,成功。 否則,若小於根結點的關鍵字值,遞迴查左子樹。 若大於根結點的關鍵字值,遞迴查右子樹。 若子樹為空白,尋找不成功。 /* //二叉樹尋找演算法 //T 二叉樹 //x 要尋找的值 */BiTree BSTSearch(BiTree T,int x){ BiTreeNode *p; if (T != NULL) { p = T; while (p !=
Time of Update: 2018-12-05
1. 十 -----> 二 (25.625)(十) 整數部分: 25/2=12......1 12/2=6 ......0 6/2=3 ......0 3/2=1 ......1 1/2=0 ......1 然後我們將餘數按從下往上的順序書寫就是:11001,那麼這個11001就是十進位25的二進位形式 小數部分: 0.625*2=1.25 0.25 *2=0.5 0.5 *2=1.0 然後我們將整數部分按從上往下的順序書寫就是:101,那麼這個101就是十進位0
Time of Update: 2018-12-05
1.實驗目的和要求目的:快速掌握C++語言編程的方法,瞭解C++的增強功能,主要內容有:(1)輸入資料流、輸出資料流的使用;(2)重載、預設參數;(3)引用;(4)new和delete運算子分配記憶體。2.實驗內容:(1) 編寫一個用輸入和輸出資料流運算子進行的輸入和輸出的程式。從鍵盤輸入兩個數,分別對兩個數進行加,減,乘和除的運算。並輸出計算結果,如: 23+123=146。 #include<iostream>using namespace std;int main(
Time of Update: 2018-12-05
這個類基本上是從LuaPlus那裡弄來的,為什麼不支援用LuaPlus,因為那東西我實在不知道怎麼編譯,能編譯通過的版本的舊版本的了,而且之前的版本有BUG的存在,使用起來有陰影,不想用了,還是自己寫個比較靠譜。因為感覺LuaPlus那個LuaFunction有點不好用,所以進行了一些改造。自己認為目前自己封裝的這個還是比較好用的。 namespace Lua_Wrapper{struct LuaNil{};inline void Push(lua_State* L, bool value){
Time of Update: 2018-12-05
C++ STL容器之 dequedeque雙端隊列容器,與vector容器相比較,明顯的優勢是很高效的添加刪除首尾元素,也較容易在任意位置插入元素。 在deque容器首尾添加元素不會使任何迭代器失效,但在首尾刪除元素會使指向被刪元素的迭代器失效,在deque容器的任何其他位置添加或刪除會使該容器的所有迭代器失效。 1.deque建立對象 (1)deque<int> de; //建立一個空的deque對象 (2)deque<int>
Time of Update: 2018-12-05
演算法設計與分析--求最大子段和問題問題描述: 給定由n個整數組成的序列(a1,a2, …,an),求該序列形如 的子段和的最大值,當所有整數均為負整數時,其最大子段和為0。利用蠻力法求解: int maxSum(int a[],int n){int maxSum = 0;int sum = 0;for(int i = 0; i < n; i++) //從第一個數開始算起{for(int j = i + 1; j < n; j++)//從i的第二個數開始算起{sum =
Time of Update: 2018-12-05
1. static成員變數類的static成員變數,當在標頭檔中聲明後,應該再在類的源檔案中定義一下:如在Test.h中有如下代碼:#pragma onceclass Test{private:static int data;};應該在Test.cpp中定義其成員變數data: #include "Test.h"int Test::data = 10;
Time of Update: 2018-12-05
public static void CopyDirectory(string source, string destination) { if (Directory.Exists(source)) { if (Directory.Exists(destination) == false) {
Time of Update: 2018-12-05
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.moreyun.com/2012/shangxiabangao_0805/144.html"); HttpWebResponse myRes = (HttpWebResponse)myReq.GetResponse(); WebHeaderCollection header = myRes.Headers;