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

給學習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>
            国产亚洲欧美激情| 亚洲大胆人体在线| 国产精品爽黄69| 韩国三级在线一区| 免费观看一区| 国内精品久久久久久久果冻传媒| 亚洲字幕在线观看| 亚洲国产你懂的| 久久夜色精品| 久久爱91午夜羞羞| 性久久久久久| 欧美在线不卡视频| 久久久久久久久久久久久久一区| 亚洲国产综合在线| 在线亚洲成人| 欧美一区观看| 欧美成人免费视频| 国产一区二区三区黄视频| 久久久噜噜噜久久久| 久久综合久久88| 在线看片一区| 午夜精品久久久久久99热软件| 亚洲欧美日本国产专区一区| 亚洲国产精品va在看黑人| 国产精品www网站| 久久久久久久综合色一本| 久久全球大尺度高清视频| 美女日韩在线中文字幕| 欧美高清一区二区| 欧美午夜寂寞影院| 久久精品国产亚洲一区二区三区| 欧美国产第一页| 久久国产精品久久精品国产| 亚洲免费不卡| 在线日本成人| 欧美91大片| 欧美久久久久久蜜桃| 久久久水蜜桃av免费网站| 国产美女高潮久久白浆| 黄色一区三区| 亚洲午夜一区| 国产视频亚洲精品| 久久综合久久美利坚合众国| 国产精品久久久亚洲一区| 亚洲人成在线免费观看| 一区二区三区四区五区在线| 久久天堂精品| 亚洲欧美日韩天堂| 日韩一区二区福利| 亚洲精品国久久99热| 久久久美女艺术照精彩视频福利播放| 久久国产精品毛片| 亚洲自拍电影| 国产精品sm| 欧美极品aⅴ影院| 欧美日韩在线三区| 久久久久久久尹人综合网亚洲| 亚洲精品国产视频| 日韩一级大片| 一本色道久久| 国产精品一区二区在线观看不卡| 欧美成人免费全部| 亚洲尤物视频在线| 久久久久久自在自线| 久久精品99| 欧美日韩一卡二卡| 欧美高清视频一区| 欧美色图首页| 欧美激情在线有限公司| 久久综合电影一区| 久久一综合视频| 欧美黄色成人网| 欧美黑人在线观看| 欧美成人一二三| 国产精品美女www爽爽爽视频| 欧美三级日韩三级国产三级| 欧美性jizz18性欧美| 欧美日韩18| 国产亚洲日本欧美韩国| 国产欧美日韩一区二区三区在线 | 999亚洲国产精| 尤物九九久久国产精品的特点| 国产日韩1区| 国产综合视频| 国产精品高潮呻吟久久| 国产一区二区三区在线观看网站| 国产精品久久久久久久久久妞妞 | 久久精品国产久精国产爱| 日韩一级欧洲| 亚洲免费视频观看| 韩日欧美一区二区三区| 亚洲精品乱码久久久久| 久久久人成影片一区二区三区 | 国产视频综合在线| 午夜视频在线观看一区二区三区 | 黄色日韩在线| 精品91在线| 亚洲精品中文字幕女同| 久久久91精品国产一区二区三区| 日韩一级网站| 亚洲在线观看视频网站| 99视频精品在线| 久久久高清一区二区三区| 国产日韩欧美不卡在线| 在线高清一区| 欧美大片免费| 欧美激情精品久久久久久黑人 | 久久国产精品电影| 久久精品一区二区三区中文字幕| 久久裸体视频| 久久一区二区视频| 欧美精品免费播放| 亚洲永久视频| 亚洲午夜激情网站| 国产一区二区三区在线观看网站| 伊人久久大香线蕉av超碰演员| 午夜精品久久久久久99热| 亚洲日本欧美| 在线观看一区视频| 欧美国产日韩一区二区三区| 99精品欧美一区| 欧美成人嫩草网站| 国产精品乱子久久久久| 亚洲一区二三| 久久久夜夜夜| 一区二区高清视频| 在线亚洲欧美视频| 亚洲网在线观看| 另类酷文…触手系列精品集v1小说| 午夜久久黄色| 国产日韩欧美综合一区| 久久久中精品2020中文| 欧美日韩日本国产亚洲在线| 欧美一区二区三区四区在线| 久久国产直播| 久久日韩精品| 久久精品人人做人人爽| 国产精品福利在线观看网址| 欧美亚洲在线视频| 亚洲伊人一本大道中文字幕| 午夜精品亚洲| 欧美亚洲自偷自偷| 日韩视频国产视频| 国产精品美女久久久久久2018| 欧美福利电影网| 亚洲欧美日韩精品在线| 国产欧美日韩在线观看| 欧美中文字幕在线| 亚洲欧洲综合另类| 蜜臀av在线播放一区二区三区| 一区在线播放| 亚洲精品九九| 国产精品久久久一区二区| 日韩写真视频在线观看| 欧美一区免费视频| 亚洲一卡久久| 樱桃视频在线观看一区| 欧美激情片在线观看| 国产精品99久久久久久宅男| 亚洲美女色禁图| 亚洲女ⅴideoshd黑人| 国产欧美视频在线观看| 亚洲欧美在线磁力| 亚洲黄色大片| 一区二区三区视频在线观看| 亚洲特级毛片| 日韩亚洲一区二区| 久久精品一区二区三区中文字幕| 欧美亚洲三级| 欧美吻胸吃奶大尺度电影| 欧美精品一区二区在线播放| 国产精品网曝门| 一区二区三区高清在线| 欧美一区二区视频网站| 午夜精品影院| 久久婷婷综合激情| 夜夜爽av福利精品导航| 久久免费视频观看| 欧美激情一区二区三区四区| 在线高清一区| 久久青草欧美一区二区三区| 亚洲高清不卡av| 欧美激情亚洲一区| 91久久黄色| 久久久久欧美| 性18欧美另类| 欧美亚日韩国产aⅴ精品中极品| 在线看片欧美| 一区二区三区精密机械公司| 久久综合九色| 欧美一区精品| 欧美性事免费在线观看| 国产老肥熟一区二区三区| 亚洲精品1区2区| 久久一区二区三区国产精品 | 一本一本久久a久久精品综合妖精| 久久免费视频在线观看| 国产精品综合网站| 久久久xxx| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ入口 |