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

給學習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>
            欧美专区18| 欧美精品日韩一区| 亚洲国产专区校园欧美| 欧美偷拍另类| 欧美日韩一区二区免费视频| 欧美国产大片| 国产精品夫妻自拍| 国产女主播一区| 精品999日本| 亚洲精品国产拍免费91在线| 99视频精品在线| 亚洲在线国产日韩欧美| 欧美一级大片在线免费观看| 欧美在线综合| 亚洲第一区在线观看| 美日韩丰满少妇在线观看| 欧美不卡视频| 中文欧美日韩| 久久精品麻豆| 欧美日韩精品免费观看| 国产日韩精品一区| 亚洲人成在线观看网站高清| 一区二区三区不卡视频在线观看| 午夜精品久久久久| 免费观看一区| 亚洲在线成人精品| 久热精品视频在线观看一区| 欧美日本一区| 黄色综合网站| 午夜国产精品影院在线观看| 久久中文字幕导航| 夜夜嗨av一区二区三区中文字幕| 久久国产99| 国产精品成人一区二区| 在线观看亚洲精品视频| 午夜精彩视频在线观看不卡| 免费成人你懂的| 亚洲一区二区三区乱码aⅴ蜜桃女| 欧美一区高清| 欧美日本簧片| 亚洲国产成人av| 久久久久久久一区| 一区二区欧美精品| 欧美日韩精品在线| 亚洲精品影视| 欧美成人午夜免费视在线看片| 午夜国产精品影院在线观看| 欧美日韩一区二区三区视频| 在线观看日韩专区| 久久精品视频免费播放| 亚洲一区二区三区免费在线观看| 欧美精品999| 亚洲二区免费| 免费成人性网站| 久久精品日韩欧美| 国产一区二区福利| 欧美亚洲系列| 亚洲一区图片| 99精品国产高清一区二区| 欧美sm视频| 久久精品视频网| 国产三级精品在线不卡| 午夜精品美女久久久久av福利| 亚洲精品国产精品久久清纯直播| 久久资源av| 亚洲人成网站在线观看播放| 亚洲高清在线视频| 欧美精品成人一区二区在线观看| 亚洲破处大片| 久久久国产一区二区三区| 午夜精品久久久久久久99热浪潮| 日韩亚洲欧美中文三级| 欧美日韩国产色视频| 亚洲图片在线| 一区二区三区视频观看| 欧美激情中文字幕乱码免费| 国产精品美女黄网| 国产日韩欧美一区二区三区四区| 性欧美超级视频| 午夜免费日韩视频| 在线观看欧美视频| 亚洲黄色高清| 欧美日韩亚洲一区二区三区在线观看| 亚洲毛片在线免费观看| 99re亚洲国产精品| 国产精品尤物福利片在线观看| 久久久成人网| 欧美激情影院| 欧美一区在线视频| 麻豆国产va免费精品高清在线| 日韩视频第一页| 亚洲影音先锋| 在线日韩精品视频| 亚洲狼人精品一区二区三区| 国产精品久久久| 麻豆av一区二区三区久久| 美日韩精品免费| 亚洲女爱视频在线| 久久久综合激的五月天| 亚洲一区二区三| 久久精品夜夜夜夜久久| 一道本一区二区| 久久久久成人精品| 亚洲在线播放| 欧美1级日本1级| 久久精品视频免费播放| 欧美黄色免费| 久久久久久久999| 欧美日韩免费一区二区三区| 久久综合一区二区三区| 国产精品v亚洲精品v日韩精品| 免费91麻豆精品国产自产在线观看| 欧美日韩国产a| 欧美sm视频| 国产小视频国产精品| 亚洲美女诱惑| 亚洲黄色成人| 欧美诱惑福利视频| 午夜精品久久久久久久久久久久久| 国产精品欧美久久| 亚洲电影在线看| 欧美揉bbbbb揉bbbbb| 狂野欧美激情性xxxx| 国产精品青草久久| 亚洲精品视频啊美女在线直播| 国产麻豆日韩欧美久久| 99精品久久| 亚洲毛片在线看| 你懂的国产精品| 蜜臀久久99精品久久久画质超高清| 国产精品一区二区久久久| 亚洲伦理中文字幕| 亚洲精品女av网站| 久久久人成影片一区二区三区| 性色av一区二区三区| 欧美日韩中文字幕日韩欧美| 亚洲国产精品一区制服丝袜| 亚洲第一视频网站| 老司机午夜免费精品视频| 久久久精品一区| 国产亚洲成年网址在线观看| 亚洲欧美久久| 欧美综合国产| 狠色狠色综合久久| 久久久亚洲国产天美传媒修理工| 久久久女女女女999久久| 韩国三级电影久久久久久| 欧美一区在线视频| 久久婷婷激情| 在线观看欧美精品| 欧美激情亚洲综合一区| 亚洲人成77777在线观看网| 99天天综合性| 国产精品video| 欧美亚洲一级| 欧美成人69av| 日韩香蕉视频| 国产精品成人va在线观看| 亚洲免费在线视频| 久久这里只有| 一区二区免费看| 国产精品视频成人| 久久成人免费网| 亚洲成色777777女色窝| 亚洲天堂激情| 国产一区二区三区四区三区四| 看片网站欧美日韩| 亚洲精品极品| 久久久国产精彩视频美女艺术照福利| 在线看不卡av| 国产精品美女久久| 蜜臀av国产精品久久久久| 亚洲精品视频免费观看| 久久国产黑丝| 夜夜嗨一区二区| 国产午夜精品一区理论片飘花| 欧美成人精品三级在线观看| 一区二区三区四区五区在线| 久久久久在线| 亚洲天堂成人在线视频| 在线成人h网| 国产精品女主播在线观看| 久久中文在线| 香蕉久久国产| 亚洲精品一区在线观看| 久久久久九九视频| 亚洲午夜精品久久| 亚洲国产一区二区三区高清| 国产精品美女久久久浪潮软件| 国内精品写真在线观看| 99re6这里只有精品视频在线观看 99re6这里只有精品 | 国产精品网站在线观看| 久久久久看片| 亚洲一品av免费观看| 欧美激情第3页| 欧美在线免费视屏| 亚洲私拍自拍| 日韩亚洲欧美一区二区三区| 国产一区二区三区日韩欧美| 欧美视频在线观看|