Stooge-sort排序

//此題是《演算法導論》的課後題,p95.// T(n) = 3T(2/3*n) +O(1)效率為指數級。    #include "stdafx.h"#include <iostream>#include <algorithm>bool Stooge_Sort(int A[], int i , int j)...{       if(A[i] > A[j])        std::swap(A[i], A[j]);    if(i+1 >= j)     

用兩個stack定義一個queue

一個堆棧用於壓如元素另一堆棧彈出元素。如果一個彈出操作遇到空堆棧,那麼就將入堆棧中的元素一次一個地傳送到出堆棧中。#include "stdafx.h"#include <stack>template<class T, class C = std::vector<T> >class Queue...{    public:        typedef typename C::vaule_type vaule_type;        typedef type

cocos2D視頻及相關資料下載

麥可cocos2d x教程_跨平台環境搭建麥可cocos2d x教程_認識遊戲開發麥可cocos2d x教程_移動平台遊戲開發介紹麥可cocos2d x教程_遊戲引擎介紹 http://pan.baidu.com/share/link?shareid=552414&uk=3408791888 cocos2D-X

boost::mpl::vector(GCC)源碼分析

//GCC支援關鍵字typeof,MSVC不支援。所以boost::mpl::vector GCC 版本的便是基於類型的識別。//在使用typeof關鍵字時,如果是求函數的傳回型別,這個函數實際上無需定義,只需要聲明即可。//下面可以看到:這個版本的vector使用函數重載來標記不同的vector參數,比如:vector<int,double>//第0位就是int。實現的方式就是利用一個函數,這個函數的傳回型別是使用一個類型封裝器,也就是//int

選擇排序:

 // SelectionSort.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>using namespace std;template<class T>void Swap(T& x, T& y)...{    int temp = x;    x =  y;    y = temp;}template&l

BOOST_PP_LOCAL_ITERATE() (局部迭代) 源碼分析

該宏位於目錄boost/preprocessor/iteration/local.hpp文檔說它的作用是:該宏將使用者自訂宏 BOOST_PP_LOCAL_MACRO 以 BOOST_PP_LOCAL_LIMITS所指定的區間中的值垂直展開。還給出了一個例子:#include <boost/preprocessor/iteration/local.hpp>template<int> struct sample;#define BOOST_PP_LOCAL_MACRO(n)

產生模板的自動機制

#include "stdafx.h"#include <iostream>#include <string>#include <typeinfo>#include <boost/mpl/vector.hpp>#include <boost/mpl/push_back.hpp>#include <boost/mpl/begin_end.hpp>#include

貼)SQL 左外串連,右外串連,全串連,內串連

http://www.blogjava.net/zolly/archive/2007/10/23/SQLJION.html 聯結條件可在 FROM 或 WHERE 子句中指定,建議在 FROM 子句中指定聯結條件。WHERE 和 HAVING 子句也可以包含搜尋條件,以進一步篩選聯結條件所選的行。 聯結可分為以下幾類: 內聯結(典型的聯結運算,使用像 = 或 <> 之類的比較子)。包括相等聯結和自然聯結。

編譯Ghostscript的陷阱

Ghostscript

字串長度拷貝串連

#include <stdio.h>/**類比C語言系統提供的strlen、strcat、strcpy**//*力求代碼簡潔,易懂,盡量和系統提供函數類似*//*字串長度*/int mystrlen(const char *str){ const char *s = str; if(NULL == str) return -1; while(*s != '\0') s++; return (s -

關於西方近代科學崛起初略看法

 第一: 形式邏輯。     光是形式邏輯不能概括。形式邏輯在一般的教科書中極度乏味,實際上它應該是如此的有趣,是那種非常聰明哲學家創造出來(亞裡士多德)。黑格爾在《哲學史講演錄》裡面對哲學史講得十分的精彩,特別是關于思辨,黑格爾花了大量的時間來討論,可見其價值的重要性。思辨是哲學的核心之一,形式邏輯只是其中的分支(亞裡士多德)。我發覺的鍛煉人的思維就是學習這些思辨,理解它所要表達的意思。這太有意思了。 第二:實驗主義。    

(一)ghostscript源碼分析之interp()函數的第二個參數

/* Main interpreter. *//* If execution terminates normally, return e_InterpreterExit. *//* If an error occurs, leave the current object in *perror_object *//* and return a (negative) error code. */static intinterp(i_ctx_t **pi_ctx_p /* context for

《演算法導論》 上的計數排序

#include <iostream>#include <string>using namespace std;const int MaxN = 40;void counting_sort(int A[],int B[], int k)...{    int C[MaxN];    //for(int i = 0; i < MaxN; i++)    //    C[i] =0;//初始化    memset(C, 0, sizeof(C)/sizeof(C[0])

(二)ghostscript源碼分析之interp()函數之IREF_NEXT宏分析

interp()函數用了大量的宏。IREF_NEXT只是其中一個宏,但是出現的頻率很高。但是透徹的理解這個宏將為理解interp()函數提供便利。它的定義形式如下:#define IREF_NEXT(ip)/ ((const ref_packed *)((const ref *)(ip) + 1))這句看似簡單的代碼實際上不那麼容易理解,而後面一些列的宏要麼與此類似,要麼間接的調用它。而ref的定義是下面這個樣子:struct ref_s { struct tas_s tas;

在std::vector下,不同記憶體配置方式效率簡單比較

#include "stdafx.h"#include <iostream>#include <vector>#include <time.h>#include <boost/pool/pool_alloc.hpp>template<typename T>class alloc{public:typedef std::size_t size_type;typedef std::ptrdiff_t

一道網友提問的解法

http://topic.csdn.net/u/20091015/15/b61e2747-5909-44d8-b32a-6b420e9306a5.html 有一個這樣的模板函數: 已知定義了一些類: class Base { public:       int dataType; }; class A:public Base { ... }; class B:public Base { ... }; class D:public B { .... }; template <class T&

(一)boost::lambda源碼分析

 // is_instance_of_n<A, B>::value is true, if type A is // an instantiation of a template B, or A derives from an instantiation // of template B//// n is the number of template arguments for B// // Example:// is_instance_of_2<std::istream,

(二) boost::lambda 源碼分析

由於boost::lambda用了boost::tuple。那麼對tuple關鍵的代碼進行分析。tuple的使用很方面,也很簡單,比如:boost::tuple<int,double,string> triple(42, 3.245, "The amazing tuple!");int a0 = triple.get<0>();double a1 = triple.get<1>();string a2 =

釋放vector記憶體的兩種方法

經常聽見有人說vector記憶體是不可以釋放的。實際上這是一種誤解, 下面提供兩種方法,各有千秋:int a[10] = {12,3,45,6,7,2,45,5,2,10};vector<int> S(a,a+10);S.swap(vector<int>());或是:vector<int>().swap(S);這是利用swap函數,和臨時對象交換,使S對象的記憶體為臨時對象的記憶體一樣,而臨時 對象的記憶體為S對象的記憶體。交換以後,臨時對象消失,釋放記憶體。

(三)boost::lambda源碼分析

 本文是lambda分析篇最重要的一篇。lambda源碼比較龐大(把宏全部展開),只是對其中的小部分進行分析,小部分足以展示其難度和運行機理。boost源碼給我的感覺對基礎知識要求很高,是對知識正確的運用(我們的朋友們已經走向了另一條路,喜馬拉雅上還是要從中國這方爬比較合適)。lambda源碼對模板技術的運用很高,比其它代碼如pool,shared_ptr等等都要厲害。總體來看mpl源碼是元編程的皎皎者,但是很難運用在實際的工作中。lambda應該是實際運用的出色者。 先看下面的代碼:#incl

總頁數: 61357 1 .... 15764 15765 15766 15767 15768 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.