Time of Update: 2018-07-18
1.總是用屬性 ( Property) 來代替可訪問的資料成員 2.在 readonly 和 const 之間,優先使用 readonly 3.在 as 和 強制類型轉換之間,優先使用 as 操作符 4.使用條件屬性 ( Conditional Attributes) 來代替條件編譯語句 #if 5.總是為自訂類重載 ToString 方法 6.區別實值型別和參考型別 7.使用不可變的實值型別( Immutable
Time of Update: 2018-07-18
轉自:http://blog.csdn.net/newhappy2008/article/details/6857098 題:有N+2個數,N個數出現了偶數次,2個數出現了奇數次(這兩個數不相等),問用O(1)的空間複雜度,找出這兩個數,不需要知道具體位置,只需要知道這兩個值。 求解:如果只有一個數出現過奇數次,這個就比較好求解了,直接將數組中的元素進行異或,異或的結果 就是只出現過奇數次的那個數。
Time of Update: 2018-07-18
Following C code is the implementation of merge sort, with the time complexity of O(nlogn). It was used in my current project to sort 148 million integers. At first I used bubbled sort, which took me hours to have the 148M integers sorted, because
Time of Update: 2018-07-18
轉自:http://www.kuqin.com/language/20120324/319283.html 一個簡單的累加求和程式: 01.TYPE S=0; 02.for(int i = 0;i < SIZE; i++) { 03. S += a[i]; 04.} 很多人都覺得這個程式寫得不好,編譯器不能產生很好的彙編代碼。於是有了以下的幾種“最佳化”: 01.#include 02.using namespace std; 03. 04.void
Time of Update: 2018-07-18
C/C++排序演算法 (2009-03-25 09:05:47) 標籤:排序演算法 迴圈次數 分類:編程開發
Time of Update: 2018-07-18
字元型轉換為字串 // C 貨幣 2.5.ToString("C"); // ¥2.50 // D 10進位數 25.ToString("D5"); // 25000 // E 科學型 25000.ToString("E"); // 2.500000E+0
Time of Update: 2018-07-18
轉自:http://blog.csdn.net/feixiaoxing/article/details/6827801 指標是編程人員的夢魘,對C語言的開發人員是如此,對C++的開發人員也是如此。特別是在C++中,如果不注意處理類中的指標,非常容易出問題。如果朋友們不相信可以看看下面的代碼: view plain class data
Time of Update: 2018-07-18
#include<iostream>#include<string>#include<queue>using namespace std;typedef int KeyType;#define NUM 13class BinSTree;class BinStreeNode{public:KeyType key;BinStreeNode *lchild;BinStreeNode *rchild;BinStreeNode(){lchild=NULL;rchild=
Time of Update: 2018-07-18
在C++中,可以為參數指定預設值。在函數調用時沒有指定與形參相對應的實參時, 就自動使用預設參數。 預設參數的文法與使用:(1)在函式宣告或定義時,直接對參數賦值。這就是預設參數; (2)在函數調用時,省略部分或全部參數。這時可以用預設參數來代替。 注意:(1)預設參數只可在函式宣告中設定一次。只有在沒有函式宣告時,才可以在函數定義中設定。(#add ,此句意為存在函式宣告和定義兩部分的時候。驗證表明有這個限制,可以隨便,但出於規範,在聲明中指定)
Time of Update: 2018-07-18
第一種理解比如說你用C++開發了一個DLL庫,為了能夠讓C語言也能夠調用你的DLL輸出(Export)的函數,你需要用extern "C"來強制編譯器不要修改你的 函數名。 通常,在C語言的標頭檔中經常可以看到類似下面這種形式的代碼: #ifdef __cplusplus extern "C" { #endif /**** some declaration or so *****/ #ifdef
Time of Update: 2018-07-18
C++中的虛函數(virtual function) 1.簡介 虛函數是C++中用於實現多態(polymorphism)的機制。核心理念就是通過基類訪問衍生類別定義的函數。假設我們有下面的類層次: class A { public: virtual void foo() { cout << "A::foo() is called" << endl;} }
Time of Update: 2018-07-18
BP(Back Propagation)網路是1986年由Rumelhart和McCelland為首的科學家小組提出,是一種按誤差逆傳播演算法訓練的多層前饋網路,是目前應用最廣泛的神經網路模型之一。BP網路能學習和存貯大量的輸入輸出模式映射關係,而無需事前揭示描述這種映射關係的數學方程。它的學習規則是使用最速下降法(梯度法),通過反向傳播來不斷調整網路的權值和閾值,使網路的誤差平方和最小。BP神經網路模型拓撲結構包括輸入層(input layer)、隱層(hide
Time of Update: 2018-07-18
C#經典試題 1, 請你說說.NET中類和結構的區別?
Time of Update: 2018-07-18
當使用者焦點離開TreeView時,TreeView選中節點仍然高亮,但是顏色太淺,幾乎看不出來。 這裡重寫一下DrawMode();可以控制選中節點顏色。 TreeView.HideSelection = false;可讓選中節點保持高亮。 參考:http://msdn.microsoft.com/zh-cn/library/system.windows.forms.treeview.hideselection(VS.80).aspx public
Time of Update: 2018-07-18
十進位轉二進位: //十進位轉二進位#include<iostream>using namespace std;void printbinary(const unsigned int val){for(int i = 16; i >= 0; i--){if(val & (1 << i))cout << "1";elsecout << "0";}}int
Time of Update: 2018-07-18
1.#include <dos.h> 2.#include <graphics.h> 3.#include <math.h> 4./*玫瑰花*/ 5.#define FNX(x) (int)(xo+(x)*1.0) 6.#define FNY(y) (int)(getmaxy()-(yo+(y)*1.0)) 7.#define FNX2(phi) cos(phi)*
Time of Update: 2018-07-18
輸入的數組格式: strinput=”001,002,003,001,001,003,005”; 要求輸出的格式: stroutput=”001,002,003,005”; 引用命名空間: using System.Collections.Generic; string strinput="001,002,003,001,001,003,005"; string
Time of Update: 2018-07-18
#include <iostream>#include <cmath>#include <Eigen/Eigen>using namespace Eigen;#define ITER_STEP (1e-5)#define ITER_CNT (100)typedef void (*func_ptr)(const VectorXd &input, const VectorXd ¶ms, VectorXd
Time of Update: 2018-07-18
後台線程和前麵線程的最大區別在於,後台線程不會阻止進程中止,,當屬於某個進程的所有前台線程都中止了,,,,公用語言運行庫就會結束該進程,所有剩餘後台線程都會停止且不會完成。 下面為示範代碼 using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace ConsoleApplication1 { class
Time of Update: 2018-07-18
昨天晚上和@buptpatriot討論函數返回指標(malloc產生的)的問題,提到字串拼接,做個總結。 #include<stdio.h>#include<stdlib.h>#include<string.h>char *join1(char *, char*);void join2(char *, char *);char *join3(char *, char*);int main(void) {char a[4] =