青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

給學習c++的新手,這些書籍都是很經典的。經典中的經典
深度探索C++對象模型
英文版:http://www.nengxia.com/soft.asp?id=5
中文版:http://www.nengxia.com/soft.asp?id=19

Modern C++ Design
http://www.nengxia.com/soft.asp?id=7

c++編程思想
第一卷:
中文版:http://www.nengxia.com/soft.asp?id=1039
英文版: Prentice Hall Bruce Eckel Thinking In C++, Second EditionVolume.1
第二卷:
中文版:http://www.nengxia.com/soft.asp?id=1040
英文版:http://www.nengxia.com/soft.asp?id=1041


c++ Programming language
中文版:http://www.nengxia.com/soft.asp?id=1038
英文版:http://www.nengxia.com/soft.asp?id=368

C++ Primer
第三版中文版:http://www.nengxia.com/soft.asp?id=6
第四版
英文版:http://www.nengxia.com/soft.asp?id=117
中文版:http://www.nengxia.com/soft.asp?id=635
c++ primer 題解
http://www.nengxia.com/soft.asp?id=17


C++ Primer plus 第4版中文:
中文版:http://www.nengxia.com/soft.asp?id=987
英文版:
Third.Editionhttp://www.nengxia.com/soft.asp?id=1037
Special.Edition:http://www.nengxia.com/soft.asp?id=369


Effective C++
中文版:http://www.nengxia.com/soft.asp?id=9
英文版:http://www.nengxia.com/soft.asp?id=1033

More Effective C++
中文版:http://www.nengxia.com/soft.asp?id=8

STL源碼剖析
http://www.nengxia.com/soft.asp?id=11


c++ template
英文版:
http://www.nengxia.com/soft.asp?id=1034
簡體中文版:
http://www.nengxia.com/soft.asp?id=15
繁體中文版:
http://www.nengxia.com/soft.asp?id=16

Effective STL
http://www.nengxia.com/soft.asp?id=54

c++ 標準庫
http://www.nengxia.com/soft.asp?id=47

Exception c++
中文版:http://www.nengxia.com/soft.asp?id=1035
英文版:http://www.nengxia.com/soft.asp?id=18

More Excetption c++
英文版:http://www.nengxia.com/soft.asp?id=20

C++ Coding Standards:
http://www.nengxia.com/soft.asp?id=114

STL輕松入門
http://www.nengxia.com/soft.asp?id=162

c/c++標準函數庫 中文版
http://www.nengxia.com/soft.asp?id=641

the design and evolution of c++
英文版:http://nengxia.com/soft.asp?id=1042

高質量C++編程指南
http://www.nengxia.com/soft.asp?id=1043



posted @ 2007-10-24 16:45 c++ 學習 閱讀(11488) | 評論 (8)編輯 收藏
 
程序員常常需要實現回調。本文將討論函數指針的基本原則并說明如何使用函數指針實現回調。注意這里針對的是普通的函數,不包括完全依賴于不同語法和語義規則的類成員函數(類成員指針將在另文中討論)。

聲明函數指針

??? 回調函數是一個程序員不能顯式調用的函數;通過將回調函數的地址傳給調用者從而實現調用。要實現回調,必須首先定義函數指針。盡管定義的語法有點不可思議,但如果你熟悉函數聲明的一般方法,便會發現函數指針的聲明與函數聲明非常類似。請看下面的例子:

void f();// 函數原型

上面的語句聲明了一個函數,沒有輸入參數并返回void。那么函數指針的聲明方法如下:

void (*) ();

??? 讓我們來分析一下,左邊圓括弧中的星號是函數指針聲明的關鍵。另外兩個元素是函數的返回類型(void)和由邊圓括弧中的入口參數(本例中參數是空)。注意本例中還沒有創建指針變量-只是聲明了變量類型。目前可以用這個變量類型來創建類型定義名及用sizeof表達式獲得函數指針的大小:

// 獲得函數指針的大小
unsigned psize = sizeof (void (*) ());?

// 為函數指針聲明類型定義
typedef void (*pfv) ();

pfv是一個函數指針,它指向的函數沒有輸入參數,返回類行為void。使用這個類型定義名可以隱藏復雜的函數指針語法。

指針變量應該有一個變量名:

void (*p) (); //p是指向某函數的指針

??? p是指向某函數的指針,該函數無輸入參數,返回值的類型為void。左邊圓括弧里星號后的就是指針變量名。有了指針變量便可以賦值,值的內容是署名匹配的函數名和返回類型。例如:

void func()?
{
/* do something */
}?
p = func;?

p的賦值可以不同,但一定要是函數的地址,并且署名和返回類型相同。

傳遞回調函數的地址給調用者

??? 現在可以將p傳遞給另一個函數(調用者)- caller(),它將調用p指向的函數,而此函數名是未知的:

void caller(void(*ptr)())
{
ptr(); /* 調用ptr指向的函數 */?
}
void func();
int main()
{
p = func;?
caller(p); /* 傳遞函數地址到調用者 */
}

??? 如果賦了不同的值給p(不同函數地址),那么調用者將調用不同地址的函數。賦值可以發生在運行時,這樣使你能實現動態綁定。

調用規范

??? 到目前為止,我們只討論了函數指針及回調而沒有去注意ANSI C/C++的編譯器規范。許多編譯器有幾種調用規范。如在Visual C++中,可以在函數類型前加_cdecl,_stdcall或者_pascal來表示其調用規范(默認為_cdecl)。C++ Builder也支持_fastcall調用規范。調用規范影響編譯器產生的給定函數名,參數傳遞的順序(從右到左或從左到右),堆棧清理責任(調用者或者被調用者)以及參數傳遞機制(堆棧,CPU寄存器等)。

??? 將調用規范看成是函數類型的一部分是很重要的;不能用不兼容的調用規范將地址賦值給函數指針。例如:

// 被調用函數是以int為參數,以int為返回值
__stdcall int callee(int);?

// 調用函數以函數指針為參數
void caller( __cdecl int(*ptr)(int));?

// 在p中企圖存儲被調用函數地址的非法操作
__cdecl int(*p)(int) = callee; // 出錯


??? 指針p和callee()的類型不兼容,因為它們有不同的調用規范。因此不能將被調用者的地址賦值給指針p,盡管兩者有相同的返回值和參數列。?
posted @ 2006-11-18 13:55 c++ 學習 閱讀(223) | 評論 (0)編輯 收藏
 
本題目是懶豬一字一字敲上電腦的,轉載請尊重懶豬的勞動成果,注明轉自懶豬的窩窩http://spaces.msn.com/davidblogs/,資源共享,謝謝合作。
懶豬稍后給出自己做的參考解答,希望能和大家多多交流。
?
編程環境:VC++6
考試時間:3小時
Problem A.Fibonacci
Input:????????? ?fib.in
Output:??????? Standard Output
Time limit:??? ?5 second
Memory limit: 64 megabytes
Offerd by :?? http://spaces.msn.com/davidblogs/
?
The Fibonacci Numbers{0,1,1,2,3,5,8,13,21,34,55...} are defined by the recurrence:
F0=0 F1=1 Fn=Fn-1+Fn-2,n>=2
Write a program to calculate the Fibonacci Numbers.
?
Input
The input file contains a number n and you are expected to calculate Fn.(0<=n<=30)

Output
Print a number Fn on a separate line,which means the nth Fibonacci Number.
?
Example
fib.in?????? Standard Output
1??????????? 1
2??????????? 1
3??????????? 2
4??????????? 3
5??????????? 5
6??????????? 8
?

Problem B.WERTYU
Input:????????? ?wertyu.in
Output:?????? ? Standard Output
Time limit:???? ?5 second
Memory limit:? 64 megabytes
Offerd by :?? http://spaces.msn.com/davidblogs/
?
A common typing error is to place the hands on the keyboard one row to the right of the correct position.So "Q" is typed as "W" and "J" is typed as "K" and so on.You are to decode a message typed in this manner.
?
` 1 2 3 4 5 6 7 8 9 0 - = BackSp
Tab Q W E R T Y U I O P [ ] \
A S D F G H J K L ; ' Enter
Z? X? C? V? B? N? M? ,? .? /
Control Alt? Space? Alt Control
?
Input
The input file consist of several lines of text.Each line may contain digits,spaces,upper case letters(except Q,A,Z),or punctuation shown above(except back-quote(') which is left to the key "1").Keys labelled with words [Tab,BackSp,Control,etc.] are not represented in the input.
?
Output
You are to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above.Spaces in the input should be echoed in the output.
?
Example
wertyu.in??????????????????? ?Standard Output
O S, GOMR YPFSU/??????? I AM FINE TODAY.
?
?
Problem C.String Matching
Input:????????? ??matching.in
Output:?????? ? Standard Output
Time limit:???? ?5 second
Memory limit:? 64 megabytes
Offerd by :?? http://spaces.msn.com/davidblogs/
?
Finding all occurrences of a pattern in a text is a problem that arises frequently in text-editing programs.Typically,the text is a document being edited,and the pattern searched for is a particular word supplied by the user.
?
We assume that the text is an array T[1..n] of length n and that the pattern is an array P[1..m] of length m<=n.We further assume that the elements of P and T are all alphabets(∑={a,b...,z}).The character arrays P and T are often called strings of characters.
?
We say that pattern P occurs with shift s in the text T if 0<=s<=n and T[s+1..s+m] = P[1..m](that is if T[s+j]=P[j],for 1<=j<=m).
?
If P occurs with shift s in T,then we call s a valid shift;otherwise,we call s a invalid shift.
Your task is to calculate the number of vald shifts for the given text T and pattern P.
?
Input
In the input file,there are two strings T and P on a line,separated by a single space.You may assume both the length of T and P will not exceed 10^6.
?
Output
You should output a number on a separate line,which indicates the number of valid shifts for the given text T and pattern P.
?
Example
matching.in????? ?Standard Output
aaaaaa a????????? ??6
abababab abab?? 3
abcdabc abdc??? ?0
?
Problem D.Exponential Form
Input:????????? ? form.in
Output:?????????Standard Output
Time limit:????? 5 second
Memory limit:? 64 megabytes
Offerd by :?? http://spaces.msn.com/davidblogs/
?
Every positive number can be presented by the exponential form.For example,
137 = 2^7 + 2^3 + 2^0
Let's present a^b by the form a(b).Then 137 is presented by 2(7)+2(3)+2(0).
Since 7 = 2^2 + 2 + 2^0 and 3 = 2 + 2^0 , 137 is finally presented by 2(2(2)+2+2(0))+2(2+2(0))+2(0).
?
Given a positive number n,your task is to present n with the exponential form which only contains the digits 0 and 2.
?
Input
The input file contains a positive integer n (n<=20000).
?
Output
You should output the exponential form of n an a single line.Note that,there should not be any additional white spaces in the line.
?
Example
form.in
137
Stardard Output
2(2(2)+2+2(0))+2(2+2(0))+2(0)
form.in
1315
Stardard Output
2(2(2+2(0))+2)+2(2(2+2(0)))+2(2(2)+2(0))+2+2(0)
posted @ 2006-03-31 19:16 c++ 學習 閱讀(925) | 評論 (0)編輯 收藏
 
我是看了msdn后,感覺還是很簡單的,只要知道三個東西
va_arg, va_start, va_end
va_arg:
typeva_arg(
?? va_listarg_ptr,
?? type
);

va_arg returns the current argument; va_start and va_end do not return values

The va_arg, va_end, and va_start macros provide a portable way to access the arguments to a function when the function takes a variable number of arguments. Two versions of the macros are available: The macros defined in STDARG.H conform to the ANSI C standard, and the macros defined in VARARGS.H are compatible with the UNIX System V definition. The macros are:

The ANSI C standard macros, defined in STDARG.H, are used as follows:

  • All required arguments to the function are declared as parameters in the usual way. va_dcl is not used with the STDARG.H macros.
  • va_start sets arg_ptr to the first optional argument in the list of arguments passed to the function. The argument arg_ptr must have va_list type. The argument prev_param is the name of the required parameter immediately preceding the first optional argument in the argument list. If prev_param is declared with the register storage class, the macro's behavior is undefined. va_start must be used before va_arg is used for the first time.
  • va_arg retrieves a value of type from the location given by arg_ptr and increments arg_ptr to point to the next argument in the list, using the size of type to determine where the next argument starts. va_arg can be used any number of times within the function to retrieve arguments from the list.

The example:

//?crt_va.c
/*?The?program?below?illustrates?passing?a?variable
?*?number?of?arguments?using?the?following?macros:
?*??????va_start????????????va_arg??????????????va_end
?*??????va_list?????????????va_dcl?(UNIX?only)
?
*/


#include?
<stdio.h>
#define?ANSI????????????/*?Comment?out?for?UNIX?version?????*/
#ifdef?ANSI?????????????
/*?ANSI?compatible?version??????????*/
#include?
<stdarg.h>
int?average(?int?first,??);
#else???????????????????/*?UNIX?compatible?version??????????*/
#include?
<varargs.h>
int?average(?va_list?);
#endif

int?main(?void?)
{
???
/*?Call?with?3?integers?(-1?is?used?as?terminator).?*/
???printf(?
"Average?is:?%d\n",?average(?2,?3,?4,?-1?)?);

???
/*?Call?with?4?integers.?*/
???printf(?
"Average?is:?%d\n",?average(?5,?7,?9,?11,?-1?)?);

???
/*?Call?with?just?-1?terminator.?*/
???printf(?
"Average?is:?%d\n",?average(?-1?)?);
}


/*?Returns?the?average?of?a?variable?list?of?integers.?*/
#ifdef?ANSI?????????????
/*?ANSI?compatible?version????*/
int?average(?int?first,??)
{
???
int?count?=?0,?sum?=?0,?i?=?first;
???va_list?marker;

???va_start(?marker,?first?);?????
/*?Initialize?variable?arguments.?*/
???
while(?i?!=?-1?)
???
{
??????sum?
+=?i;
??????count
++;
??????i?
=?va_arg(?marker,?int);
???}

???va_end(?marker?);??????????????
/*?Reset?variable?arguments.??????*/
???
return(?sum???(sum?/?count)?:?0?);
}

#else???????/*?UNIX?compatible?version?must?use?old-style?definition.??*/
int?average(?va_alist?)
va_dcl
{
???
int?i,?count,?sum;
???va_list?marker;

???va_start(?marker?);????????????
/*?Initialize?variable?arguments.?*/
???
for(?sum?=?count?=?0;?(i?=?va_arg(?marker,?int))?!=?-1;?count++?)
??????sum?
+=?i;
???va_end(?marker?);??????????????
/*?Reset?variable?arguments.??????*/
???
return(?sum???(sum?/?count)?:?0?);
}

#endif


最主要的是average 函數
開始時申明一個va_list marker
后來調用va_start(marker);
再后來調用va_arg(marker, int)
最后結束時調用va_end(marker):

posted @ 2006-03-21 12:39 c++ 學習 閱讀(769) | 評論 (0)編輯 收藏
 

?

給出一個前序遍歷,給出一個中序遍歷,要求把樹輸出
給出算法答案如下:
main()
{
Datatype?preorder[n],?inorder[n];
Struct?link
* BT;
if (n? > ? 0 )
BT?
= ?creatBT( 0 ,?n - 1 ,? 0 ,?n? - ? 1 );
return (BT);
}


struct ?link * ?createBT( int ?prestart,? int ?preend,? int ?instart,? int ?inend)
{
p?
= ?( struct ?link * )malloc( sizeof ( struct ?link);
p
-> lchild? = ? null ;
p
-> rchild? = ? null ;
p
-> data? = ?preorder[prestart];
if (prestart? > ?preend)
{?
??
for ( int ?i? = ?instart;?inorder[i]? != ?preorder[start];?i ++ );
?
if (i? > ?instart)
???p
-> lchild? = ?createBT(prestart? + ? 1 ,?prestart - ?instart? + ? 1 ,?instart,?i? - ? 1 );
?
if (i? < ?inend)
??p
-> rchild? = ?createBT(prestart? - ?instart? + ?i? + ? 1 ,?preend,?i? + ? 1 ,?inend);????????
}
??
?
return ?(p):
}

posted @ 2006-03-21 10:55 c++ 學習 閱讀(689) | 評論 (0)編輯 收藏
僅列出標題
共3頁: 1 2 3 
 
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            一本色道久久综合亚洲精品不| 亚洲精品色婷婷福利天堂| 国产精品第一区| 欧美精品乱人伦久久久久久| 在线一区二区三区做爰视频网站| 制服诱惑一区二区| 欧美尤物巨大精品爽| 亚洲视频1区| 亚洲字幕一区二区| 亚洲欧美中日韩| 亚洲欧美春色| 午夜精品福利一区二区蜜股av| 在线一区欧美| 正在播放欧美视频| 午夜日韩激情| 免费视频一区二区三区在线观看| 欧美国产专区| 一区二区三区日韩| 久久久久亚洲综合| 欧美电影免费观看高清完整版| 欧美视频一二三区| 99精品久久久| 欧美高清你懂得| 久久人人爽人人爽爽久久| 国产精品久久久久久模特| 亚洲图片欧洲图片av| 99pao成人国产永久免费视频| 亚洲性感美女99在线| 蜜臀av一级做a爰片久久| 国产精品视频成人| 亚洲视频在线观看免费| 亚洲日韩成人| 性欧美大战久久久久久久久| 欧美日韩中文字幕精品| 亚洲精一区二区三区| 欧美成人午夜影院| 欧美 日韩 国产精品免费观看| 精品成人久久| 亚洲黄色免费网站| 欧美久久久久中文字幕| 亚洲一区二区免费在线| 欧美精品一区二区三区久久久竹菊| 国产一区二三区| 欧美成人有码| 欧美日韩1区2区| 午夜精品亚洲一区二区三区嫩草| 一区二区日本视频| 国产一区久久| 亚洲福利小视频| 欧美日韩国产探花| 久久久久久久久久久成人| 欧美成人第一页| 亚洲永久免费| 久久免费高清视频| 亚洲免费一级电影| 老牛影视一区二区三区| 亚洲欧美精品在线| 欧美激情一级片一区二区| 欧美一区二区在线| 欧美成人免费播放| 久久久91精品| 欧美三级黄美女| 亚洲黄色性网站| 国产午夜精品一区二区三区欧美 | 亚洲国产成人在线| 日韩视频在线永久播放| 影音先锋亚洲精品| 一区二区三区欧美激情| 午夜精品区一区二区三| 亚洲自拍偷拍视频| 蜜臀av一级做a爰片久久| 欧美午夜精品一区| 亚洲黑丝一区二区| 亚洲国产成人av| 欧美亚洲在线观看| 欧美一区免费| 国产欧美日韩视频| 在线不卡免费欧美| 美日韩精品免费| 亚洲精品午夜精品| 欧美一区在线看| 在线观看欧美| 欧美精品尤物在线| 亚洲一二三区在线| 久久资源av| 在线亚洲国产精品网站| 国产精品hd| 久久久久久久尹人综合网亚洲| 美女脱光内衣内裤视频久久影院| 在线观看91精品国产麻豆| 欧美mv日韩mv国产网站app| 99视频精品全部免费在线| 欧美一区国产一区| 91久久久一线二线三线品牌| 国产精品99一区二区| 免费观看国产成人| 香港久久久电影| 日韩亚洲精品在线| 欧美成人r级一区二区三区| 亚洲日本欧美日韩高观看| 国产精品久久久久久久久久妞妞| 欧美一区二区三区免费观看视频| 亚洲人成人一区二区三区| 久久综合福利| 欧美一区中文字幕| 久久久久网址| 麻豆视频一区二区| 久久久久久久性| 欧美一区二区观看视频| 欧美国内亚洲| 毛片基地黄久久久久久天堂| 午夜国产精品视频| 欧美一区二区性| 久久精品国产一区二区三区免费看| 日韩午夜电影| 亚洲无毛电影| 欧美呦呦网站| 久久频这里精品99香蕉| 欧美精品福利视频| 欧美精品色综合| 国产精品日韩欧美综合| 国产免费成人在线视频| 伊人成人在线视频| 亚洲精品视频免费| 亚洲一级特黄| 久久久国产精品一区二区中文| 久久都是精品| 亚洲国产精品久久久久久女王| 欧美成人r级一区二区三区| 亚洲日本成人女熟在线观看| 一片黄亚洲嫩模| 欧美综合二区| 欧美精品在线观看播放| 国内精品国语自产拍在线观看| 日韩午夜剧场| 欧美fxxxxxx另类| 一区二区三区视频观看| 欧美一区二区三区在线播放| 欧美成人一区二免费视频软件| 欧美手机在线| 一区二区黄色| 欧美激情视频一区二区三区在线播放 | 欧美亚洲在线播放| 欧美巨乳在线| 91久久夜色精品国产网站| 欧美一级久久久久久久大片| 亚洲人体大胆视频| 欧美成人首页| 欧美成人精品三级在线观看| 国产精品久久久久久亚洲毛片| 亚洲精品久久久久久久久| 久久视频免费观看| 亚洲永久免费观看| 国产日韩亚洲欧美精品| 亚洲自拍偷拍网址| 亚洲欧美在线免费| 国产一区二三区| 亚洲福利视频免费观看| 欧美三级第一页| 久久免费午夜影院| 美女主播视频一区| 亚洲一区二区三区高清不卡| 亚洲一区二区在线免费观看视频| 国产精品久久久久久久9999 | 狠狠88综合久久久久综合网| 久久黄色小说| 欧美了一区在线观看| 香蕉久久一区二区不卡无毒影院 | 小嫩嫩精品导航| 99精品视频免费观看视频| 一区二区三区四区五区精品| 国产欧美一区二区精品秋霞影院 | 国产日韩精品视频一区二区三区| 久久久久九九视频| 欧美日韩在线亚洲一区蜜芽| 久久久综合网站| 国产精品久久久久久久7电影| 欧美激情aⅴ一区二区三区| 欧美日韩中文字幕在线| 亚洲激情婷婷| 亚洲精品欧美极品| 久久亚洲综合网| 久久久久久久波多野高潮日日| 国产精品男gay被猛男狂揉视频| 亚洲国产黄色| 亚洲美女色禁图| 欧美成人久久| 亚洲精品老司机| 黄色亚洲精品| 亚洲一区二区黄色| 欧美午夜不卡视频| 99精品欧美一区二区三区 | 欧美日韩精品免费观看视一区二区| 欧美成黄导航| 一本一本久久a久久精品综合麻豆 一本一本久久a久久精品牛牛影视 | 欧美电影在线观看| 在线观看精品视频| 欧美人与禽猛交乱配| 一个人看的www久久| 午夜精品三级视频福利|