Time of Update: 2015-05-09
標籤: Introduction:Before the possibilities of the new C++ language standard, C++11, the use of templates was quite limited when it came to implementing for instance function objects (functors) & tuple
Time of Update: 2015-05-10
標籤:黑馬程式員------<a href="http://www.itheima.com" target="blank">Java培訓、Android培訓、iOS培訓、.Net培訓</a>、期待與您交流! -------第五 複雜構造資料類型01 結構體的定義:一般形式:struct 結構體名{ 類型標識符1 成員1; 類型標識符2 成員2;
Time of Update: 2015-05-09
標籤:c++ 最佳化 C++傳回值最佳化和具名傳回值最佳化是編譯器的最佳化,在大多數情況下能提高效能,但是卻難以受程式員控制。C++11中加入了move語義的支援,由此對RVO和NRVO會造成一定影響。下面以一段代碼來說明。RVO和NRVO在分別在copy/move construct,copy/move assignment八種簡單情況,測試條件是g++ 4.8.2和clang++ 3.4,預設最佳化。#include
Time of Update: 2015-05-09
標籤:c++ stl 這次把C++中的STL的一些東西練習一下下,STL全稱為 Standard Template Library ,也就是標準模板庫, 要使用STL,要瞭解以下幾個基本概念:
Time of Update: 2015-05-10
標籤:c c++ java leetcode python Problem:Given an array S of n integers, are there elements a, b, c,
Time of Update: 2015-05-09
標籤:c++ 結構體 結構體數組 結構體指標 指標 //用結構體完成:編程求出3個學生中某個學生的平均成績#include <iostream>#include <string.h>using namespace std;struct student{char *name;double score[3];
Time of Update: 2015-05-08
標籤:#include<stdio.h>#define f(a,b) a##b#define g(a) #a#define h(a) g(a)int main(){ printf("%s\n",h(f(1,2))); 宏h(a) 是g(a),沒有#,所以需要進行宏展開 printf("%s\n",g(f(1,2))); //宏g(a) 有#,所以不展開 return
Time of Update: 2015-05-08
標籤:leetcode c c++ java python Problem:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate
Time of Update: 2015-05-08
標籤: 1 #include<stdlib.h> 2 3 #define SIZE 10 4 typedef char ele; 5 6 typedef struct{ 7 ele *e; 8 int front; 9 int rear;10 }cycleQueue;11 12 13 //initQueue14 void initQueue(cycleQueue *q){15 q = (cycleQueue
Time of Update: 2015-05-06
標籤:1.Algorithm Gossip: 老鼠走迷官(一)說明:老鼠走迷宮是遞迴求解的基本題型,我們在二維陣列中使用2表示迷宮牆壁,使用1來表示老鼠的行走路徑,試以程式求出由入口至出口的路徑。解法:老鼠的走法有上、左、下、右四個方向,在每前進一格之後就選一個方向前進,無法前進時退回選擇下一個可前進方向,如此在陣列中依序測試四個方向,直到走到出口為止,這是遞迴的基本題。代碼:#include<stdio.h>#include<stdlib.h>int
Time of Update: 2015-05-06
標籤:浮點型資料一、非整數的表示除了整數,平時的計算也離不開非整數,即帶有小數部分的那些數。在數字系統中,整數和非整數合稱為有理數,有理數和無理數合稱為實數(好吧,這和本文主旨沒關係,但為了顯示一下我曾經是數學系的學生。。。)非整數由一個”.“號來凸顯,十進位標記法中,”.“號左邊的數位權為10的正整數冪,冪值按離小數點的距離遠近依次為0、1、2...而右邊為10的負整數冪,冪值由近及遠依次為-1、-2、-3...例如:12.25 = 1 * 10 ^ 1 +
Time of Update: 2015-05-05
標籤:演算法 機率與統計 最近實驗室的項目需要實現類比檔案訪問序列,要求單位時間內的資料請求次數符合泊松分布,而兩次請求見的時間間隔符合指數分布。沒辦法只好重新撿起已經丟掉多時的機率知識。於是也就有了這篇關於在C語言下符合泊松分布和指數分布的隨機數產生器的實現。泊松分布在實際的案例中,當某一事件,比如進站乘客數量,電話交換器接收到的通話請求以固定的瞬時速率λ獨立且隨機地出現時,就可以認為該事件在單位時間內發生的次數符合泊松分布。
Time of Update: 2015-05-07
標籤://希爾排序#include<iostream>#include<array>using namespace std;template<class T>void shell_sort(T&, int);int main(){ array<int, 10> arr = {1,2,3,5,4,6,7,8,9,0}; shell_sort(arr, arr.size()); &
Time of Update: 2015-05-06
標籤:1.冒泡排序冒泡排序是O(N^2)複雜度的排序演算法,效率較低,需要N趟遍曆,每次將候選集中最小的數通過交換浮到最上面;template <typename Type>void BubbleSort(vector<Type> &arraySort, int lowIndex, int hightIndex){ bool bChange; for (int i=lowIndex;
Time of Update: 2015-05-07
標籤:c++ 演算法 全排列 遞迴演算法 中心思想: 設R={r1,r2,…,rn}是要進行排列的n個元素,Ri=R-{ri}. Perm(X)表示在全排列Perm(X)的每一個排列前加上首碼ri得到的排列。 (1)當n=1時,Perm(R)=(r),其中r是集合R中唯一的元素; (2)當n>1時,Perm(R)可由(r1)+Perm(
Time of Update: 2015-05-10
標籤:Preson類using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ClassLibrary1{ class Person { public string _name; public int _age; public char _gender;
Time of Update: 2015-05-10
標籤: //if (bm.Name == "DateYear") //年 //{ // bm.Select(); //
Time of Update: 2015-05-10
標籤: 1.先講概念:.Net Framework提供了對應的System.Xml.Seriazliation.XmlSerializer負責把對象序列化到XML,和從XML中還原序列化為對象。Serializer的使用比較直觀,需要多注意的是XML序列化相關的Attribute,怎麼把這些attribute應用到我們的對象,以及對象公用屬性上面去,產生滿足預期格式的XML。
Time of Update: 2015-05-09
標籤:c#中的各種泛型上一篇文章簡單瞭解了一下強型別以及泛型的知識。其實,在.net類庫中有很多的泛型定義,最典型也是我們用的最多的就是List<>和Dictionary<Tkey,Tvalue>兩個泛型集合。這隻是微軟我們提供的,在實際開發中,我們很多時候還需要自己定義一些泛型,今天就接著上次的內容來具體學習一下泛型的各種定義。一、泛型類1.定義 //泛型類,泛型的好處,還是代碼重用。 // where yzk : struct泛型約束
Time of Update: 2015-05-07
標籤:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConvertToUtf8{ public class ClassFun { public static byte[] Pathology_ConvertToBinary(string source) { byte[] utf8Prefix =