锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美大片免费久久精品三p ,国产精品久久久久久久电影 ,国产精品99久久久久久久女警http://www.shnenglu.com/hunter/category/8854.html鐪婥++鍜岀畻娉曪紝鐪兼唱鍝楀摋鐨勩傘傘?/description>zh-cnTue, 01 Jun 2010 08:07:06 GMTTue, 01 Jun 2010 08:07:06 GMT60STL 鍫嗘帓搴忎嬌鐢ㄥ拰浣撲細(杞?http://www.shnenglu.com/hunter/archive/2010/05/29/116663.htmlhunterhunterFri, 28 May 2010 23:37:00 GMThttp://www.shnenglu.com/hunter/archive/2010/05/29/116663.htmlhttp://www.shnenglu.com/hunter/comments/116663.htmlhttp://www.shnenglu.com/hunter/archive/2010/05/29/116663.html#Feedback0http://www.shnenglu.com/hunter/comments/commentRss/116663.htmlhttp://www.shnenglu.com/hunter/services/trackbacks/116663.html鍒涘緩涓涓簩鍙夋爲(wèi)錛屼笅闈?wbr>鏄嚑涓父鐢ㄥ嚱鏁扮殑浣跨敤鏂規(guī)硶鍜屼唬琛ㄧ殑鎰忔?br>#include
#include
#include
#include
using namespace std;

錛?錛夊垱寤轟竴涓暟緇勶紝騫舵坊鍔犳暟鎹?br>    vector v_Arry;
    v_Arry.push_back(5);
    v_Arry.push_back(6);
    v_Arry.push_back(4);
    v_Arry.push_back(8);
    v_Arry.push_back(2);
    v_Arry.push_back(3);
    v_Arry.push_back(7);
    v_Arry.push_back(1);
    v_Arry.push_back(9);
    v_Arry.push_back(10);
    v_Arry.push_back(55);

錛?錛塵ake_heap錛坴_Arry.begin錛堬級, v_Arry.end錛堬級, less()) //寤哄爢錛堝叾瀹炲氨鏄緩浜屽弶鏍?wèi)锛?鏍硅妭鐐規(guī)槸鏈澶у鹼紝鍏舵瘡涓涓妭鐐歸兘灝忎簬鎴栫瓑浜庡叾鐖惰妭鐐癸紱浣跨敤greater()鍒欑浉鍙嶏紝鏍硅妭鐐規(guī)槸鏈灝忓鹼紝鍏舵瘡涓涓妭鐐?wbr>閮藉ぇ浜庢垨絳変簬鍏剁埗鑺傜偣

錛?錛夋鏃跺彲浠ヨ緭鍑烘煡鐪嬩竴涓嬪緩濂界殑鍫嗘槸涓嶆槸涓涓爣鍑嗙殑浜屽弶鏍?br>鎴戠殑杈撳嚭緇撴灉鏄細55錛?0錛?錛?錛?錛?wbr>3錛?錛?錛?錛?錛?wbr>2
鍙樻垚浜屽弶鏍?wèi)灏辨槸濡備笅锛?br> <!--[if !vml]--><!--[endif]--> <!--[if !vml]--><!--[endif]-->

 

緇撴灉涓嶆槸鍞竴鍗曚竴瀹氳婊¤凍鐖惰妭鐐瑰拰瀛愯妭鐐圭殑澶у皬鍏崇郴銆?br>錛?錛塸op_heap(v_Arry.begin(), v_Arry.end());//鎶婃牴鑺傜偣縐誨埌鏈熬錛屽茍娌℃湁鍒犻櫎
     v_Arry.pop_back();//鍒犻櫎璇ヨ妭鐐?br>    姝ゆ椂杈撳嚭緇撴灉錛?0錛?wbr>9錛?錛?錛?錛?錛?wbr>4錛?錛?錛?
浜屽弶鏍?wèi)濡備笅锛?

 

錛?錛塿_Arry.push_back(55); //鍙槸娣誨姞鏁版嵁鏀懼埌瀛愯妭鐐?br>    push_heap(v_Arry.begin(), v_Arry.end());//寰浜屽弶鏍?wbr>涓彃鍏ユ暟鎹紝婊¤凍瀛愯妭鐐瑰皬浜庣瓑浜庣埗鑺傜偣
姝ゆ椂杈撳嚭緇撴灉錛?5錛?wbr>10錛?錛?錛?錛?錛?錛?錛?錛?錛?
浜屽弶鏍?wèi)濡備笅锛?br>

 

錛?錛塻ort_heap(v_Arry.begin(), v_Arry.end());//瀵逛簩鍙夋爲(wèi)鎵鏈夎妭鐐硅繘琛屾帓搴?br>姝ゆ椂杈撳嚭緇撴灉錛?錛?錛?錛?錛?錛?錛?錛?錛?錛?0錛?5

錛?錛塮ind ( v_Arry.begin(), v_Arry.end()錛?value );// 浠巄egin鍒癳nd鏌ユ壘value錛岃嫢鎵?wbr>涓嶅埌錛岃繑鍥瀍nd

鍘熸枃鍦板潃錛?a >http://blog.zol.com.cn/1356/article_1355249.html


hunter 2010-05-29 07:37 鍙戣〃璇勮
]]>
榪愮敤璁℃暟鎺掑簭榪涜鍩烘暟鎺掑簭http://www.shnenglu.com/hunter/archive/2010/03/11/109411.htmlhunterhunterThu, 11 Mar 2010 03:08:00 GMThttp://www.shnenglu.com/hunter/archive/2010/03/11/109411.htmlhttp://www.shnenglu.com/hunter/comments/109411.htmlhttp://www.shnenglu.com/hunter/archive/2010/03/11/109411.html#Feedback0http://www.shnenglu.com/hunter/comments/commentRss/109411.htmlhttp://www.shnenglu.com/hunter/services/trackbacks/109411.html閲嶅瀵規(guī)墍鏈夌殑d浣嶆暟瀛楅兘榪涜鎺掑簭錛屼粎闇瑕乨閬嶅氨鍙互灝嗕竴鍫嗗崱鐗囪繘琛屾帓搴忋?br>榪欓噷鍙堣繍鐢ㄤ簡鍩烘暟鎺掑簭鐨勬柟娉曪紝鎵浠ユ葷殑鏃墮棿澶嶆潅搴︿負O(n*d)銆?br>
#include <stdio.h>
#include 
<stdlib.h>
#include 
<iostream>
#include 
<cmath>
using namespace std;

void CountSort(int a[], int b[],int num,int d)   //璁℃暟鎺掑簭
{
    
int* c = new int[10];
    
int index;
    
for (int i=0;i<=9;i++)
       c[i]
=0;
    
int size = num;
    
for (int j=0;j<size;j++)
    
{
        index
=a[j]%(int)pow(10.0,d)/(int)pow(10.0,d-1);
        c[index]
++;
    }

    
//c[i]鍖呭惈絳変簬i鐨勫厓绱犱釜鏁?/span>
    for (i=1;i<=9;i++)
       c[i]
=c[i]+c[i-1];
    
//c[i]鍖呭惈灝忎簬絳変簬i鐨勫厓绱犱釜鏁?/span>
    for (j=size-1;j>=0;j--)
    
{
        index
=a[j]%(int)pow(10.0,d)/(int)pow(10.0,d-1);
        b[c[index]
-1]=a[j];
        c[index]
--;
    }


    
for (j=0;j<size;j++)    //鏇存柊涓嬈℃帓搴忓悗鐨刟鏁扮粍
    {
        a[j]
=b[j];
    }

        delete [] c;
}


void RadixSort(int a[],int b[],int d,int num)   //鍩烘暟鎺掑簭
{
    
for(int i=1;i<=d;i++)
        CountSort(a,b,num,i);
}



void main()
{
    
int num,d;
    cout
<<"杈撳叆涓暟鍙婁綅鏁?/span>"<<endl;
    cin
>>num>>d;
    
int* a = new int[num];
    
int* b = new int[num];
    cout
<<"鎺掑簭鍓嶏細"<<endl;
    
for(int i=0;i<num;i++)
    
{
        cin
>>a[i];
    }

        
    RadixSort(a,b,d,num);

    cout
<<"鎺掑簭鍚庯細"<<endl;
    
for (int j=0;j<num;j++)
    
{
        cout
<<b[j]<<endl;
    }


    delete [] a;
    delete [] b;
}



hunter 2010-03-11 11:08 鍙戣〃璇勮
]]>
sizeof鐢ㄦ硶錛堣漿錛?/title><link>http://www.shnenglu.com/hunter/archive/2010/03/10/109400.html</link><dc:creator>hunter</dc:creator><author>hunter</author><pubDate>Wed, 10 Mar 2010 15:36:00 GMT</pubDate><guid>http://www.shnenglu.com/hunter/archive/2010/03/10/109400.html</guid><wfw:comment>http://www.shnenglu.com/hunter/comments/109400.html</wfw:comment><comments>http://www.shnenglu.com/hunter/archive/2010/03/10/109400.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/hunter/comments/commentRss/109400.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/hunter/services/trackbacks/109400.html</trackback:ping><description><![CDATA[<span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span><span style="TEXT-ALIGN: left; LINE-HEIGHT: 21px; FONT-FAMILY: simsun, 瀹嬩綋, sans-serif; COLOR: rgb(70,70,70); FONT-SIZE: 14px" class=Apple-style-span> <p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px" dir=ltr>C璇█涓垽鏂暟鎹被鍨嬮暱搴︾<br>鐢ㄦ硶<br> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>sizeof(綾誨瀷璇存槑絎︼紝鏁扮粍鍚嶆垨琛ㄨ揪寮?;<br>鎴?br> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>sizeof 鍙橀噺鍚?br><br>1. 瀹氫箟錛?br>sizeof鏄疌/C++涓殑涓涓搷浣滅錛坥perator錛夋槸涔燂紝綆鍗曠殑璇村叾浣滅敤灝辨槸榪斿洖涓涓璞℃垨鑰呯被鍨嬫墍鍗犵殑鍐呭瓨瀛楄妭鏁般?br>MSDN涓婄殑瑙i噴涓猴細<br>The sizeof keyword gives the amount of storage, in bytes, associated with a variable or a type (including aggregate types). This keyword returns a value of type size_t.<br>鍏惰繑鍥炲肩被鍨嬩負size_t錛屽湪澶存枃浠秙tddef.h涓畾涔夈傝繖鏄竴涓緷璧栦簬緙栬瘧緋葷粺鐨勫鹼紝涓鑸畾涔変負<br>typedef unsigned int size_t;<br>涓栦笂緙栬瘧鍣ㄦ灄鏋楁繪伙紝浣嗕綔涓轟竴涓鑼冿紝瀹冧滑閮戒細淇濊瘉char銆乻igned char鍜寀nsigned<br>char鐨剆izeof鍊間負1錛屾瘯绔焎har鏄垜浠紪紼嬭兘鐢ㄧ殑鏈灝忔暟鎹被鍨嬨?br>2. 璇硶錛?br>sizeof鏈変笁縐嶈娉曞艦寮忥紝濡備笅錛?br>1) sizeof( object ); // sizeof( 瀵硅薄 );<br>2) sizeof( type_name ); // sizeof( 綾誨瀷 );<br>3) sizeof object; // sizeof 瀵硅薄;<br>鎵浠ワ紝<br>int i;<br>sizeof( i ); <wbr><span id="hvzpftn" class=Apple-converted-space> </span>// ok<br>sizeof i; <wbr> <wbr> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>// ok<br>sizeof( int ); // ok<br>sizeof int; <wbr> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>// error<br>鏃㈢劧鍐欐硶3鍙互鐢ㄥ啓娉?浠f浛錛屼負姹傚艦寮忕粺涓浠ュ強鍑忓皯鎴戜滑澶ц剳鐨勮礋鎷咃紝絎?縐嶅啓娉曪紝蹇樻帀瀹冨惂錛佸疄闄呬笂錛宻izeof璁$畻瀵硅薄鐨勫ぇ灝忎篃鏄漿鎹㈡垚瀵瑰璞$被鍨嬬殑璁$畻錛屼篃灝辨槸璇達紝鍚岀綾誨瀷鐨勪笉鍚屽璞″叾sizeof鍊奸兘鏄竴鑷寸殑銆傝繖閲岋紝瀵硅薄鍙互榪涗竴姝ュ歡浼歌嚦琛ㄨ揪寮忥紝鍗硈izeof鍙互瀵逛竴涓〃杈懼紡姹傚鹼紝緙栬瘧鍣ㄦ牴鎹〃杈懼紡鐨勬渶緇堢粨鏋滅被鍨嬫潵紜畾澶у皬錛屼竴鑸笉浼氬琛ㄨ揪寮忚繘琛岃綆椼傚錛?br>sizeof( 2 ); <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>// 2鐨勭被鍨嬩負int錛屾墍浠ョ瓑浠蜂簬 sizeof( int );<br>sizeof( 2 + 3.14 ); <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>// 3.14鐨勭被鍨嬩負double錛?涔熶細琚彁鍗囨垚double綾誨瀷錛屾墍浠ョ瓑浠蜂簬 sizef(double)<br></p> <p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">涔熷彲浠ュ涓涓嚱鏁拌皟鐢ㄦ眰鍊鹼紝鍏剁粨鏋滄槸鍑芥暟榪斿洖綾誨瀷鐨勫ぇ灝忥紝鍑芥暟騫朵笉浼氳璋冪敤錛屾垜浠潵鐪嬩竴涓畬鏁寸殑渚嬪瓙錛?br>char foo()<br>{<br>printf("foo() has been called.\n");<br>return 'a';<br>}<br>int main()<br>{<br>size_t sz = sizeof( foo() ); // foo() 鐨勮繑鍥炲肩被鍨嬩負char錛屾墍浠z = sizeof(char )錛宖oo()騫朵笉浼氳璋冪敤<br>printf("sizeof( foo() ) = %d\n", sz);<br>}<br>C99鏍囧噯瑙勫畾錛屽嚱鏁般佷笉鑳界‘瀹氱被鍨嬬殑琛ㄨ揪寮忎互鍙婁綅鍩燂紙bit-field錛夋垚鍛樹笉鑳借璁$畻sizeof鍊鹼紝鍗充笅闈㈣繖浜涘啓娉曢兘鏄敊璇殑錛?br>sizeof( foo );// error<br>void foo2() { }<br>sizeof( foo2() );// error<br>struct S<br>{<br> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span> <wbr> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>unsigned int f1 : 1;<br> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span> <wbr> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>unsigned int f2 : 5;<br> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span> <wbr> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>unsigned int f3 : 12;<br>};<br>sizeof( S.f1 );// error<br>3. sizeof鐨勫父閲忔?br>sizeof鐨勮綆楀彂鐢熷湪緙栬瘧鏃跺埢錛屾墍浠ュ畠鍙互琚綋浣滃父閲忚〃杈懼紡浣跨敤錛屽錛?br>char ary[ sizeof( int ) * 10 ]; // ok<br>鏈鏂扮殑C99鏍囧噯瑙勫畾sizeof涔熷彲浠ュ湪榪愯鏃跺埢榪涜璁$畻錛屽涓嬮潰鐨勭▼搴忓湪Dev-C++涓彲浠ユ紜墽琛岋細<br>int n;<br>n = 10; // n鍔ㄦ佽祴鍊?br>char ary[n]; // C99涔熸敮鎸佹暟緇勭殑鍔ㄦ佸畾涔?br>printf("%d\n", sizeof(ary)); // ok. 杈撳嚭10<br>浣嗗湪娌℃湁瀹屽叏瀹炵幇C99鏍囧噯鐨勭紪璇戝櫒涓氨琛屼笉閫氫簡錛屼笂闈㈢殑浠g爜鍦╒C6涓氨閫氫笉榪囩紪璇戙傛墍浠ユ垜浠渶濂借繕鏄涓簊izeof鏄湪緙栬瘧鏈熸墽琛岀殑錛岃繖鏍蜂笉浼氬甫鏉ラ敊璇紝璁╃▼搴忕殑鍙Щ妞嶆у己浜涖?br>4. 鍩烘湰鏁版嵁綾誨瀷鐨剆izeof<br>榪欓噷鐨勫熀鏈暟鎹被鍨嬫寚short銆乮nt銆乴ong銆乫loat銆乨ouble榪欐牱鐨勭畝鍗曞唴緗暟鎹被鍨嬶紝鐢變簬瀹冧滑閮芥槸鍜岀郴緇熺浉鍏崇殑錛屾墍浠ュ湪涓嶅悓鐨勭郴緇熶笅鍙栧煎彲鑳戒笉鍚岋紝榪欏姟蹇呭紩璧鋒垜浠殑娉ㄦ剰錛屽敖閲忎笉瑕佸湪榪欐柟闈㈢粰鑷繁紼嬪簭鐨勭Щ妞嶉犳垚楹葷儲銆?br>涓鑸殑錛屽湪32浣嶇紪璇戠幆澧冧腑錛宻izeof(int)鐨勫彇鍊間負4銆?br>5. 鎸囬拡鍙橀噺鐨剆izeof<br>瀛﹁繃鏁版嵁緇撴瀯鐨勪綘搴旇鐭ラ亾鎸囬拡鏄竴涓緢閲嶈鐨勬蹇碉紝瀹冭褰曚簡鍙︿竴涓璞$殑鍦板潃銆傛棦鐒舵槸鏉ュ瓨鏀懼湴鍧鐨勶紝閭d箞瀹冨綋鐒剁瓑浜庤綆楁満鍐呴儴鍦板潃鎬葷嚎鐨勫搴︺傛墍浠ュ湪32浣嶈綆楁満涓紝涓涓寚閽堝彉閲忕殑榪斿洖鍊煎繀瀹氭槸4錛堟敞鎰忕粨鏋滄槸浠ュ瓧鑺備負鍗曚綅錛夛紝鍙互棰勮錛屽湪灝嗘潵鐨?4浣嶇郴緇熶腑鎸囬拡鍙橀噺鐨剆izeof緇撴灉涓?銆?br>char* pc = "abc";<br>int* pi;<br>string* ps;<br>char** ppc = &pc;<br>void (*pf)();// 鍑芥暟鎸囬拡<br>sizeof( pc ); // 緇撴灉涓?<br>sizeof( pi ); // 緇撴灉涓?<br>sizeof( ps ); // 緇撴灉涓?<br>sizeof( ppc ); // 緇撴灉涓?<br>sizeof( pf );// 緇撴灉涓?<br>鎸囬拡鍙橀噺鐨剆izeof鍊間笌鎸囬拡鎵鎸囩殑瀵硅薄娌℃湁浠諱綍鍏崇郴錛屾鏄敱浜庢墍鏈夌殑鎸囬拡鍙橀噺鎵鍗犲唴瀛樺ぇ灝忕浉絳夛紝鎵浠FC娑堟伅澶勭悊鍑芥暟浣跨敤涓や釜鍙傛暟WPARAM銆丩PARAM灝辮兘浼犻掑悇縐嶅鏉傜殑娑堟伅緇撴瀯錛堜嬌鐢ㄦ寚鍚戠粨鏋勪綋鐨勬寚閽堬級銆?br>6. 鏁扮粍鐨剆izeof<br>鏁扮粍鐨剆izeof鍊肩瓑浜庢暟緇勬墍鍗犵敤鐨勫唴瀛樺瓧鑺傛暟錛屽錛?br>char a1[] = "abc";<br>int a2[3];<br>sizeof( a1 ); // 緇撴灉涓?錛屽瓧絎?鏈熬榪樺瓨鍦ㄤ竴涓狽ULL緇堟絎?br>sizeof( a2 ); // 緇撴灉涓?*4=12錛堜緷璧栦簬int錛?br>涓浜涙湅鍙嬪垰寮濮嬫椂鎶妔izeof褰撲綔浜嗘眰鏁扮粍鍏冪礌鐨勪釜鏁幫紝鐜板湪錛屼綘搴旇鐭ラ亾榪欐槸涓嶅鐨勶紝閭d箞搴旇鎬庝箞姹傛暟緇勫厓绱犵殑涓暟鍛asy錛岄氬父鏈変笅闈袱縐嶅啓娉曪細<br>int c1 = sizeof( a1 ) / sizeof( char ); // 鎬婚暱搴?鍗曚釜鍏冪礌鐨勯暱搴?br>int c2 = sizeof( a1 ) / sizeof( a1[0] ); // 鎬婚暱搴?絎竴涓厓绱犵殑闀垮害<br>鍐欏埌榪欓噷錛屾彁涓闂紝涓嬮潰鐨刢3錛宑4鍊煎簲璇ユ槸澶氬皯鍛?br>void foo3(char a3[3])<br>{<br>int c3 = sizeof( a3 ); // c3 ==<br>}<br>void foo4(char a4[])<br>{<br>int c4 = sizeof( a4 ); // c4 ==<br>}<br>涔熻褰撲綘璇曞浘鍥炵瓟c4鐨勫兼椂宸茬粡鎰忚瘑鍒癱3絳旈敊浜嗭紝鏄殑錛宑3!=3銆傝繖閲屽嚱鏁板弬鏁癮3宸蹭笉鍐嶆槸鏁扮粍綾誨瀷錛岃屾槸铚曞彉鎴愭寚閽堬紝鐩稿綋浜巆har* a3錛屼負浠涔堜粩緇嗘兂鎯沖氨涓嶉毦鏄庣櫧錛屾垜浠皟鐢ㄥ嚱鏁癴oo1鏃訛紝紼嬪簭浼氬湪鏍堜笂鍒嗛厤涓涓ぇ灝忎負3鐨勬暟緇勫悧涓嶄細錛佹暟緇勬槸“浼犲潃”鐨勶紝璋冪敤鑰呭彧闇灝嗗疄鍙傜殑鍦板潃浼犻掕繃鍘伙紝鎵浠3鑷劧涓烘寚閽堢被鍨嬶紙char*錛夛紝c3鐨勫間篃灝變負4銆?br>7. 緇撴瀯浣撶殑sizeof<br>榪欐槸鍒濆鑰呴棶寰楁渶澶氱殑涓涓棶棰橈紝鎵浠ヨ繖閲屾湁蹇呰澶氳垂鐐圭瑪澧ㄣ傝鎴戜滑鍏堢湅涓涓粨鏋勪綋錛?br>struct S1<br>{<br>char c;<br>int i;<br>};<br>闂畇izeof(s1)絳変簬澶氬皯鑱槑鐨勪綘寮濮嬫濊冧簡錛宑har鍗?涓瓧鑺傦紝int鍗?涓瓧鑺傦紝閭d箞鍔犺搗鏉ュ氨搴旇鏄?銆傛槸榪欐牱鍚椾綘鍦ㄤ綘鏈哄櫒涓婅瘯榪囦簡鍚椾篃璁鎬綘鏄鐨勶紝浣嗗緢鍙兘浣犳槸閿欑殑錛乂C6涓寜榛樿璁劇疆寰楀埌鐨勭粨鏋滀負8銆?br>Why涓轟粈涔堝彈浼ょ殑鎬繪槸鎴?br>璇蜂笉瑕佹伯涓э紝鎴戜滑鏉ュソ濂界悽紓ㄤ竴涓媠izeof鐨勫畾涔夆斺攕izeof鐨勭粨鏋滅瓑浜庡璞℃垨鑰呯被鍨嬫墍鍗犵殑鍐呭瓨瀛楄妭鏁幫紝濂藉惂錛岄偅灝辮鎴戜滑鏉ョ湅鐪婼1鐨勫唴瀛樺垎閰嶆儏鍐碉細<br>S1 s1 = { 'a', 0xFFFFFFFF };<br>瀹氫箟涓婇潰鐨勫彉閲忓悗錛屽姞涓婃柇鐐癸紝榪愯紼嬪簭錛岃瀵焥1鎵鍦ㄧ殑鍐呭瓨錛屼綘鍙戠幇浜嗕粈涔?br>浠ユ垜鐨刅C6.0涓轟緥錛宻1鐨勫湴鍧涓?x0012FF78錛屽叾鏁版嵁鍐呭濡備笅錛?br>0012FF78: 61 CC CC CC FF FF FF FF<br>鍙戠幇浜嗕粈涔堟庝箞涓棿澶規(guī)潅浜?涓瓧鑺傜殑CC鐪嬬湅MSDN涓婄殑璇存槑錛?br>When applied to a structure type or variable, sizeof returns the actual size, which may include padding bytes inserted for alignment.<br>鍘熸潵濡傛錛岃繖灝辨槸浼犺涓殑瀛楄妭瀵歸綈鍟婏紒涓涓噸瑕佺殑璇濋鍑虹幇浜嗐?br>涓轟粈涔堥渶瑕佸瓧鑺傚榻愯綆楁満緇勬垚鍘熺悊鏁欏鎴戜滑榪欐牱鏈夊姪浜庡姞蹇綆楁満鐨勫彇鏁伴熷害錛屽惁鍒欏氨寰楀鑺辨寚浠ゅ懆鏈熶簡銆備負姝わ紝緙栬瘧鍣ㄩ粯璁や細瀵圭粨鏋勪綋榪涜澶勭悊錛堝疄闄呬笂鍏跺畠鍦版柟鐨勬暟鎹彉閲忎篃鏄姝わ級錛岃瀹藉害涓?鐨勫熀鏈暟鎹被鍨嬶紙short絳夛級閮戒綅浜庤兘琚?鏁撮櫎鐨勫湴鍧涓婏紝璁╁搴︿負4鐨勫熀鏈暟鎹被鍨嬶紙int絳夛級閮戒綅浜庤兘琚?鏁撮櫎鐨勫湴鍧涓婏紝浠ユ綾繪帹銆傝繖鏍鳳紝涓や釜鏁頒腑闂村氨鍙兘闇瑕佸姞鍏ュ~鍏呭瓧鑺傦紝鎵浠ユ暣涓粨鏋勪綋鐨剆izeof鍊煎氨澧為暱浜嗐?br>璁╂垜浠氦鎹竴涓婼1涓璫har涓巌nt鐨勪綅緗細<br>struct S2<br>{<br>int i;<br>char c;<br>};<br>鐪嬬湅sizeof(S2)鐨勭粨鏋滀負澶氬皯錛屾庝箞榪樻槸8鍐嶇湅鐪嬪唴瀛橈紝鍘熸潵鎴愬憳c鍚庨潰浠嶇劧鏈?涓~鍏呭瓧鑺傦紝榪欏張鏄負浠涔堝晩鍒潃鎬ワ紝涓嬮潰鎬葷粨瑙勫緥銆?br>瀛楄妭瀵歸綈鐨勭粏鑺傚拰緙栬瘧鍣ㄥ疄鐜扮浉鍏籌紝浣嗕竴鑸岃█錛屾弧瓚充笁涓噯鍒欙細<br>1) 緇撴瀯浣撳彉閲忕殑棣栧湴鍧鑳藉琚叾鏈瀹藉熀鏈被鍨嬫垚鍛樼殑澶у皬鎵鏁撮櫎錛?br>2) 緇撴瀯浣撴瘡涓垚鍛樼浉瀵逛簬緇撴瀯浣撻鍦板潃鐨勫亸縐婚噺錛坥ffset錛夐兘鏄垚鍛樺ぇ灝忕殑鏁存暟鍊嶏紝濡傛湁闇瑕佺紪璇戝櫒浼氬湪鎴愬憳涔嬮棿鍔犱笂濉厖瀛楄妭錛坕nternal adding錛夛紱<br>3) 緇撴瀯浣撶殑鎬誨ぇ灝忎負緇撴瀯浣撴渶瀹藉熀鏈被鍨嬫垚鍛樺ぇ灝忕殑鏁存暟鍊嶏紝濡傛湁闇瑕佺紪璇戝櫒浼氬湪鏈鏈竴涓垚鍛樹箣鍚庡姞涓婂~鍏呭瓧鑺傦紙trailing padding錛夈?br>瀵逛簬涓婇潰鐨勫噯鍒欙紝鏈夊嚑鐐歸渶瑕佽鏄庯細<br>1) 鍓嶉潰涓嶆槸璇寸粨鏋勪綋鎴愬憳鐨勫湴鍧鏄叾澶у皬鐨勬暣鏁板嶏紝鎬庝箞鍙堣鍒板亸縐婚噺浜嗗憿鍥犱負鏈変簡絎?鐐瑰瓨鍦紝鎵浠ユ垜浠氨鍙互鍙冭檻鎴愬憳鐨勫亸縐婚噺錛岃繖鏍鋒濊冭搗鏉ョ畝鍗曘傛兂鎯充負浠涔堛?br>緇撴瀯浣撴煇涓垚鍛樼浉瀵逛簬緇撴瀯浣撻鍦板潃鐨勫亸縐婚噺鍙互閫氳繃瀹弌ffsetof()鏉ヨ幏寰楋紝榪欎釜瀹忎篃鍦╯tddef.h涓畾涔夛紝濡備笅錛?br> <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>#define offsetof(s,m) (size_t)&(((s *)0)->m)<br>渚嬪錛屾兂瑕佽幏寰桽2涓璫鐨勫亸縐婚噺錛屾柟娉曚負<br>size_t pos = offsetof(S2, c);// pos絳変簬4<br>2) 鍩烘湰綾誨瀷鏄寚鍓嶉潰鎻愬埌鐨勫儚char銆乻hort銆乮nt銆乫loat銆乨ouble榪欐牱鐨勫唴緗暟鎹被鍨嬶紝榪欓噷鎵璇寸殑“鏁版嵁瀹藉害”灝辨槸鎸囧叾sizeof鐨勫ぇ灝忋傜敱浜庣粨鏋勪綋鐨勬垚鍛樺彲浠ユ槸澶嶅悎綾誨瀷錛屾瘮濡傚彟澶栦竴涓粨鏋勪綋錛屾墍浠ュ湪瀵繪壘鏈瀹藉熀鏈被鍨嬫垚鍛樻椂錛屽簲褰撳寘鎷鍚堢被鍨嬫垚鍛樼殑瀛愭垚鍛橈紝鑰屼笉鏄妸澶嶅悎鎴愬憳鐪嬫垚鏄竴涓暣浣撱備絾鍦ㄧ‘瀹氬鍚堢被鍨嬫垚鍛樼殑鍋忕Щ浣嶇疆鏃跺垯鏄皢澶嶅悎綾誨瀷浣滀負鏁翠綋鐪嬪緟銆?br>榪欓噷鍙欒堪璧鋒潵鏈夌偣鎷楀彛錛屾濊冭搗鏉ヤ篃鏈夌偣鎸犲ご錛岃繕鏄鎴戜滑鐪嬬湅渚嬪瓙鍚э紙鍏蜂綋鏁板間粛浠C6涓轟緥錛屼互鍚庝笉鍐嶈鏄庯級錛?br>struct S3<br>{<br>char c1;<br>S1 s;<br>char c2;<br>};<br>S1鐨勬渶瀹界畝鍗曟垚鍛樼殑綾誨瀷涓篿nt錛孲3鍦ㄨ冭檻鏈瀹界畝鍗曠被鍨嬫垚鍛樻椂鏄皢S1“鎵撴暎”鐪嬬殑錛屾墍浠3鐨勬渶瀹界畝鍗曠被鍨嬩負int錛岃繖鏍鳳紝閫氳繃S3瀹氫箟鐨勫彉閲忥紝鍏跺瓨鍌ㄧ┖闂撮鍦板潃闇瑕佽4鏁撮櫎錛屾暣涓猻izeof(S3)鐨勫間篃搴旇琚?鏁撮櫎銆?br>c1鐨勫亸縐婚噺涓?錛宻鐨勫亸縐婚噺鍛㈣繖鏃秙鏄竴涓暣浣擄紝瀹冧綔涓虹粨鏋勪綋鍙橀噺涔熸弧瓚沖墠闈笁涓噯鍒欙紝鎵浠ュ叾澶у皬涓?錛屽亸縐婚噺涓?錛宑1涓巗涔嬮棿渚塊渶瑕?涓~鍏呭瓧鑺傦紝鑰宑2涓巗涔嬮棿灝變笉闇瑕佷簡錛屾墍浠2鐨勫亸縐婚噺涓?2錛岀畻涓奵2鐨勫ぇ灝忎負13錛?3鏄笉鑳借4鏁撮櫎鐨勶紝榪欐牱鏈熬榪樺緱琛ヤ笂3涓~鍏呭瓧鑺傘傛渶鍚庡緱鍒皊izeof(S3)鐨勫間負16銆?br>閫氳繃涓婇潰鐨勫彊榪幫紝鎴戜滑鍙互寰楀埌涓涓叕寮忥細<br>緇撴瀯浣撶殑澶у皬絳変簬鏈鍚庝竴涓垚鍛樼殑鍋忕Щ閲忓姞涓婂叾澶у皬鍐嶅姞涓婃湯灝劇殑濉厖瀛楄妭鏁扮洰錛屽嵆錛?br>sizeof( struct ) = offsetof( last item ) + sizeof( last item ) + sizeof( trailing padding )<br>鍒拌繖閲岋紝鏈嬪弸浠簲璇ュ緇撴瀯浣撶殑sizeof鏈変簡涓涓叏鏂扮殑璁よ瘑錛屼絾涓嶈楂樺叴寰楀お鏃╋紝鏈変竴涓獎鍝峴izeof鐨勯噸瑕佸弬閲忚繕鏈鎻愬強錛岄偅渚挎槸緙栬瘧鍣ㄧ殑pack鎸囦護銆傚畠鏄敤鏉ヨ皟鏁寸粨鏋勪綋瀵歸綈鏂瑰紡鐨勶紝涓嶅悓緙栬瘧鍣ㄥ悕縐板拰鐢ㄦ硶鐣ユ湁涓嶅悓錛孷C6涓氳繃#pragma pack瀹炵幇錛屼篃鍙互鐩存帴淇敼/Zp緙栬瘧寮鍏熾?pragma pack鐨勫熀鏈敤娉曚負錛?pragma pack( n )錛宯涓哄瓧鑺傚榻愭暟錛屽叾鍙栧間負1銆?銆?銆?銆?6錛岄粯璁ゆ槸8錛屽鏋滆繖涓兼瘮緇撴瀯浣撴垚鍛樼殑sizeof鍊煎皬錛岄偅涔?br>璇ユ垚鍛樼殑鍋忕Щ閲忓簲璇ヤ互姝ゅ間負鍑嗭紝鍗蟲槸璇達紝緇撴瀯浣撴垚鍛樼殑鍋忕Щ閲忓簲璇ュ彇浜岃呯殑鏈灝忓鹼紝<br>鍏紡濡備笅錛?br>offsetof( item ) = min( n, sizeof( item ) )<br>鍐嶇湅紺轟緥錛?br>#pragma pack(push) <wbr> <wbr><span id="hvzpftn" class=Apple-converted-space> </span>// 灝嗗綋鍓峱ack璁劇疆鍘嬫爤淇濆瓨<br>#pragma pack(2) // 蹇呴』鍦ㄧ粨鏋勪綋瀹氫箟涔嬪墠浣跨敤<br>struct S1<br>{<br>char c;<br>int i;<br>};<br>struct S3<br>{<br>char c1;<br>S1 s;<br>char c2;<br>};<br>#pragma pack(pop) // 鎭㈠鍏堝墠鐨刾ack璁劇疆<br>璁$畻sizeof(S1)鏃訛紝min(2, sizeof(i))鐨勫間負2錛屾墍浠鐨勫亸縐婚噺涓?錛屽姞涓妔izeof(i)絳変簬6錛岃兘澶熻2鏁撮櫎錛屾墍浠ユ暣涓猄1鐨勫ぇ灝忎負6銆?br>鍚屾牱錛屽浜巗izeof(S3)錛宻鐨勫亸縐婚噺涓?錛宑2鐨勫亸縐婚噺涓?錛屽姞涓妔izeof(c2)絳変簬9錛屼笉鑳借2鏁撮櫎錛屾坊鍔犱竴涓~鍏呭瓧鑺傦紝鎵浠izeof(S3)絳変簬10銆?br><br>鐜板湪錛屾湅鍙嬩滑鍙互杞繪澗鐨勫嚭涓鍙f皵浜嗭紝:)<br>榪樻湁涓鐐硅娉ㄦ剰錛?#8220;絀虹粨鏋勪綋”錛堜笉鍚暟鎹垚鍛橈級鐨勫ぇ灝忎笉涓?錛岃屾槸1銆傝瘯鎯充竴涓?#8220;涓嶅崰絀洪棿”鐨勫彉閲忓浣曡鍙栧湴鍧銆佷袱涓笉鍚岀殑“絀虹粨鏋勪綋”鍙橀噺鍙堝浣曞緱浠ュ尯鍒嗗憿浜庢槸錛?#8220;絀虹粨鏋勪綋”鍙橀噺涔熷緱琚瓨鍌紝榪欐牱緙栬瘧鍣ㄤ篃灝卞彧鑳戒負鍏跺垎閰嶄竴涓瓧鑺傜殑絀洪棿鐢ㄤ簬鍗犱綅浜嗐傚涓嬶細<br>struct S5 { };<br>sizeof( S5 ); // 緇撴灉涓?<br>8. 鍚綅鍩熺粨鏋勪綋鐨剆izeof<br>鍓嶉潰宸茬粡璇磋繃錛屼綅鍩熸垚鍛樹笉鑳藉崟鐙鍙杝izeof鍊鹼紝鎴戜滑榪欓噷瑕佽璁虹殑鏄惈鏈変綅鍩熺殑緇撴瀯浣撶殑sizeof錛屽彧鏄冭檻鍒板叾鐗規(guī)畩鎬ц屽皢鍏朵笓闂ㄥ垪浜嗗嚭鏉ャ?br>C99瑙勫畾int銆乽nsigned int鍜宐ool鍙互浣滀負浣嶅煙綾誨瀷錛屼絾緙栬瘧鍣ㄥ嚑涔庨兘瀵規(guī)浣滀簡鎵╁睍錛屽厑璁稿叾瀹冪被鍨嬬被鍨嬬殑瀛樺湪銆備嬌鐢ㄤ綅鍩熺殑涓昏鐩殑鏄帇緙╁瓨鍌紝鍏跺ぇ鑷磋鍒欎負錛?br>1) 濡傛灉鐩擱偦浣嶅煙瀛楁鐨勭被鍨嬬浉鍚岋紝涓斿叾浣嶅涔嬪拰灝忎簬綾誨瀷鐨剆izeof澶у皬錛屽垯鍚庨潰鐨勫瓧孌靛皢绱ч偦鍓嶄竴涓瓧孌靛瓨鍌紝鐩村埌涓嶈兘瀹圭撼涓烘錛?br>2) 濡傛灉鐩擱偦浣嶅煙瀛楁鐨勭被鍨嬬浉鍚岋紝浣嗗叾浣嶅涔嬪拰澶т簬綾誨瀷鐨剆izeof澶у皬錛屽垯鍚庨潰鐨勫瓧孌靛皢浠庢柊鐨勫瓨鍌ㄥ崟鍏冨紑濮嬶紝鍏跺亸縐婚噺涓哄叾綾誨瀷澶у皬鐨勬暣鏁板嶏紱<br>3) 濡傛灉鐩擱偦鐨勪綅鍩熷瓧孌電殑綾誨瀷涓嶅悓錛屽垯鍚勭紪璇戝櫒鐨勫叿浣撳疄鐜版湁宸紓錛孷C6閲囧彇涓嶅帇緙╂柟寮忥紝Dev-C++閲囧彇鍘嬬緝鏂瑰紡錛?br>4) 濡傛灉浣嶅煙瀛楁涔嬮棿絀挎彃鐫闈炰綅鍩熷瓧孌碉紝鍒欎笉榪涜鍘嬬緝錛?br>5) 鏁翠釜緇撴瀯浣撶殑鎬誨ぇ灝忎負鏈瀹藉熀鏈被鍨嬫垚鍛樺ぇ灝忕殑鏁存暟鍊嶃?br>榪樻槸璁╂垜浠潵鐪嬬湅渚嬪瓙銆?br>紺轟緥1錛?br>struct BF1<br>{<br>char f1 : 3;<br>char f2 : 4;<br>char f3 : 5;<br>};<br>鍏跺唴瀛樺竷灞涓猴細<br>|_f1__|__f2__|_|____f3___|____|<br>|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|<br>0 3 7 8 1316<br>浣嶅煙綾誨瀷涓篶har錛岀1涓瓧鑺備粎鑳藉綰充笅f1鍜宖2錛屾墍浠2琚帇緙╁埌絎?涓瓧鑺備腑錛岃宖3鍙?br>鑳戒粠涓嬩竴涓瓧鑺傚紑濮嬨傚洜姝izeof(BF1)鐨勭粨鏋滀負2銆?br>紺轟緥2錛?br>struct BF2<br>{<br>char f1 : 3;<br>short f2 : 4;<br>char f3 : 5;<br>};<br>鐢變簬鐩擱偦浣嶅煙綾誨瀷涓嶅悓錛屽湪VC6涓叾sizeof涓?錛屽湪Dev-C++涓負2銆?br>紺轟緥3錛?br>struct BF3<br>{<br>char f1 : 3;<br>char f2;<br>char f3 : 5;<br>};<br>闈炰綅鍩熷瓧孌電┛鎻掑湪鍏朵腑錛屼笉浼氫駭鐢熷帇緙╋紝鍦╒C6鍜孌ev-C++涓緱鍒扮殑澶у皬鍧囦負3銆?br>9. 鑱斿悎浣撶殑sizeof<br>緇撴瀯浣撳湪鍐呭瓨緇勭粐涓婃槸欏哄簭寮忕殑錛岃仈鍚堜綋鍒欐槸閲嶅彔寮忥紝鍚勬垚鍛樺叡浜竴孌靛唴瀛橈紝鎵浠ユ暣涓仈鍚堜綋鐨剆izeof涔熷氨鏄瘡涓垚鍛榮izeof鐨勬渶澶у箋傜粨鏋勪綋鐨勬垚鍛樹篃鍙互鏄鍚堢被鍨嬶紝榪欓噷錛屽鍚堢被鍨嬫垚鍛樻槸琚綔涓烘暣浣撹冭檻鐨勩?br>鎵浠ワ紝涓嬮潰渚嬪瓙涓紝U鐨剆izeof鍊肩瓑浜巗izeof(s)銆?br>union U<br>{<br>int i;<br>char c;<br>S1 s;<br>};<br><br><br>杞嚜錛?a >http://blog.sina.com.cn/s/blog_5af743940100ctd9.html</a></p> </span></span> <img src ="http://www.shnenglu.com/hunter/aggbug/109400.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/hunter/" target="_blank">hunter</a> 2010-03-10 23:36 <a href="http://www.shnenglu.com/hunter/archive/2010/03/10/109400.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>璁℃暟鎺掑簭http://www.shnenglu.com/hunter/archive/2010/03/10/109399.htmlhunterhunterWed, 10 Mar 2010 15:29:00 GMThttp://www.shnenglu.com/hunter/archive/2010/03/10/109399.htmlhttp://www.shnenglu.com/hunter/comments/109399.htmlhttp://www.shnenglu.com/hunter/archive/2010/03/10/109399.html#Feedback0http://www.shnenglu.com/hunter/comments/commentRss/109399.htmlhttp://www.shnenglu.com/hunter/services/trackbacks/109399.html璁℃暟鎺掑簭鐨勫熀鏈濇兂灝辨槸瀵規(guī)瘡涓涓緭鍏ュ厓绱燲錛岀‘瀹氬嚭灝忎簬X鐨勫厓绱犱釜鏁般?br>鏈変簡榪欎竴淇℃伅灝卞彲浠ユ妸X鐩存帴鏀懼埌瀹冨湪鏈緇堣緭鍑烘暟緇勪腑鐨勪綅緗笂銆?br>渚嬪錛屽鏋滄湁17涓厓绱犲皬浜嶺錛屽垯X灝卞睘浜庣18涓緭鍑轟綅緗?br>鍦ㄨ鏁版帓搴忕畻娉曠殑浠g爜涓紝鎴戜滑鍋囧畾杈撳叆鏄釜鏁扮粍A[0...n-1]錛宭ength[A]=n銆傚彟澶栬繕闇瑕佷袱涓暟緇勶細瀛樻斁鎺掑簭緇撴灉鐨凚[0...n-1]錛屼互鍙婃彁渚涗復(fù)鏃跺瓨鍌ㄥ尯鐨凜[0...k].
#include <stdio.h>
#include 
<stdlib.h>
#include 
<iostream>
using namespace std;

void CountSort(int a[], int b[],int k,int num)
{
    
int* c = new int[k+1];
    
for (int i=0;i<=k;i++)
       c[i]
=0;
    
int size = num;
    
for (int j=0;j<size;j++)
       c[a[j]]
++;
    
//c[i]鍖呭惈絳変簬i鐨勫厓绱犱釜鏁?/span>
    for (i=1;i<=k;i++)
       c[i]
=c[i]+c[i-1];
    
//c[i]鍖呭惈灝忎簬絳変簬i鐨勫厓绱犱釜鏁?/span>
    for (j=size-1;j>=0;j--)
    
{
        b[c[a[j]]
-1]=a[j];
        c[a[j]]
--;
    }


        delete [] c;
}

void main()
{
    
int num,max;
    cout
<<"杈撳叆鏈澶ф暣鏁板強杈撳叆涓暟"<<endl;
    cin
>>max;
    cin
>>num;
    
int* a = new int[num];
    
int* b = new int[num];
    cout
<<"鎺掑簭鍓嶏細"<<endl;
    
for(int i=0;i<num;i++)
    
{
        cin
>>a[i];
        
if (a[i]>max)
            i
--;
    }

        
    CountSort(a,b,max,num);

    cout
<<"鎺掑簭鍚庯細"<<endl;
    
for (int j=0;j<num;j++)
    
{
        cout
<<b[j]<<endl;
    }


    delete [] a;
    delete [] b;
}



hunter 2010-03-10 23:29 鍙戣〃璇勮
]]>
蹇熸帓搴忓強浜屽垎鏌ユ壘http://www.shnenglu.com/hunter/archive/2010/03/09/109321.htmlhunterhunterTue, 09 Mar 2010 14:05:00 GMThttp://www.shnenglu.com/hunter/archive/2010/03/09/109321.htmlhttp://www.shnenglu.com/hunter/comments/109321.htmlhttp://www.shnenglu.com/hunter/archive/2010/03/09/109321.html#Feedback0http://www.shnenglu.com/hunter/comments/commentRss/109321.htmlhttp://www.shnenglu.com/hunter/services/trackbacks/109321.html
#include <stdio.h>
#include 
<stdlib.h>
#include 
<iostream>
using namespace std;

int Partition(int a[],int p,int r)
{
    
int ran=rand()%(r-p+1)+p;       //闅忓嵆閫夊彇鍗叺
    swap(a[ran],a[r]);
    
int x=a[r];
    
int i=p-1;
    
for (int j=p;j<r;j++)
    
{
        
if (a[j]<=x)               //灝忎簬鍗叺鐨勫艱繘琛屽鎹?/span>
        {
            i
++;
            swap(a[i],a[j]);
        }

    }

    swap(a[i
+1],a[r]);
    
return i+1;
}
   

void QuickSort(int a[],int p,int r)
{
    
int q;
    
if (p<r)
    
{
        q
=Partition(a,p,r);
        QuickSort(a,p,q
-1);
        QuickSort(a,q
+1,r);
    }

}


int BinarySearch(int a[],int min,int max,int x)
{
    
int mid;
    
while (min<max)
    
{
        mid
=min+(max-min)/2;
        
if (a[mid]>=x)
            max
=mid;
        
else
            min
=mid+1;     //鑻ヤ笉鍔犱竴鍙兘瀛樺湪鏃犻檺寰幆鐨勭粨鏋?/span>
    }

    
if (a[min]==x)
        
return min;
    
else if(a[max]==x)
        
return max;
    
else
        
return -1;
}

void main()
{
    
int num;
    cin
>>num;
    
int* a = new int[num];
    cout
<<"鎺掑簭鍓嶏細"<<endl;
    
for(int i=0;i<num;i++)
        cin
>>a[i];
    QuickSort(a,
0,num-1);
    cout
<<"鎺掑簭鍚庯細"<<endl;
    
for (int j=0;j<num;j++)
    
{
        cout
<<a[j]<<endl;
    }

    cout
<<"杈撳叆瑕佹煡鎵劇殑鏁?/span>"<<endl;
    
int x;
    cin
>>x;
    
int result=BinarySearch(a,0,num-1,x);
    
if (result>=0)
        cout
<<"鐩爣浣嶇疆涓?"<<result+1<<endl;
    
else
        cout
<<"鐩爣涓嶅湪鏁扮粍涓?/span>"<<endl;
}



hunter 2010-03-09 22:05 鍙戣〃璇勮
]]>
鍫嗘帓搴?/title><link>http://www.shnenglu.com/hunter/archive/2010/03/07/109145.html</link><dc:creator>hunter</dc:creator><author>hunter</author><pubDate>Sun, 07 Mar 2010 14:08:00 GMT</pubDate><guid>http://www.shnenglu.com/hunter/archive/2010/03/07/109145.html</guid><wfw:comment>http://www.shnenglu.com/hunter/comments/109145.html</wfw:comment><comments>http://www.shnenglu.com/hunter/archive/2010/03/07/109145.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/hunter/comments/commentRss/109145.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/hunter/services/trackbacks/109145.html</trackback:ping><description><![CDATA[銆婄畻娉曞璁恒嬩腑鍏稿瀷鐨勬渶澶у爢鎺掑簭<br><br> <div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><span style="COLOR: #000000">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdlib.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">vector</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">template</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> T</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> Max_Heap(T a[],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> size)<br><img id=Codehighlighter1_153_410_Open_Image onclick="this.style.display='none'; Codehighlighter1_153_410_Open_Text.style.display='none'; Codehighlighter1_153_410_Closed_Image.style.display='inline'; Codehighlighter1_153_410_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_153_410_Closed_Image onclick="this.style.display='none'; Codehighlighter1_153_410_Closed_Text.style.display='none'; Codehighlighter1_153_410_Open_Image.style.display='inline'; Codehighlighter1_153_410_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_153_410_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_153_410_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> r </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">i </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> l </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">i </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> largest;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (l</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">size </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> a[l]</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">a[i])<br><img id=Codehighlighter1_236_254_Open_Image onclick="this.style.display='none'; Codehighlighter1_236_254_Open_Text.style.display='none'; Codehighlighter1_236_254_Closed_Image.style.display='inline'; Codehighlighter1_236_254_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_236_254_Closed_Image onclick="this.style.display='none'; Codehighlighter1_236_254_Closed_Text.style.display='none'; Codehighlighter1_236_254_Open_Image.style.display='inline'; Codehighlighter1_236_254_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_236_254_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_236_254_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        largest </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> l;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        largest </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> i;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (r</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">size </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> a[r] </span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">a[largest])<br><img id=Codehighlighter1_312_330_Open_Image onclick="this.style.display='none'; Codehighlighter1_312_330_Open_Text.style.display='none'; Codehighlighter1_312_330_Closed_Image.style.display='inline'; Codehighlighter1_312_330_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_312_330_Closed_Image onclick="this.style.display='none'; Codehighlighter1_312_330_Closed_Text.style.display='none'; Codehighlighter1_312_330_Open_Image.style.display='inline'; Codehighlighter1_312_330_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_312_330_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_312_330_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        largest </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> r;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (largest </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> i)<br><img id=Codehighlighter1_352_408_Open_Image onclick="this.style.display='none'; Codehighlighter1_352_408_Open_Text.style.display='none'; Codehighlighter1_352_408_Closed_Image.style.display='inline'; Codehighlighter1_352_408_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_352_408_Closed_Image onclick="this.style.display='none'; Codehighlighter1_352_408_Closed_Text.style.display='none'; Codehighlighter1_352_408_Open_Image.style.display='inline'; Codehighlighter1_352_408_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_352_408_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_352_408_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        swap(a[largest],a[i]);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        Max_Heap(a,largest,size);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">template</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> T</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> Build_Max_Heap(T a[],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> size)<br><img id=Codehighlighter1_467_526_Open_Image onclick="this.style.display='none'; Codehighlighter1_467_526_Open_Text.style.display='none'; Codehighlighter1_467_526_Closed_Image.style.display='inline'; Codehighlighter1_467_526_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_467_526_Closed_Image onclick="this.style.display='none'; Codehighlighter1_467_526_Closed_Text.style.display='none'; Codehighlighter1_467_526_Open_Image.style.display='inline'; Codehighlighter1_467_526_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_467_526_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_467_526_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">size</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br><img id=Codehighlighter1_499_524_Open_Image onclick="this.style.display='none'; Codehighlighter1_499_524_Open_Text.style.display='none'; Codehighlighter1_499_524_Closed_Image.style.display='inline'; Codehighlighter1_499_524_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_499_524_Closed_Image onclick="this.style.display='none'; Codehighlighter1_499_524_Closed_Text.style.display='none'; Codehighlighter1_499_524_Open_Image.style.display='inline'; Codehighlighter1_499_524_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_499_524_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_499_524_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        Max_Heap(a,i,size);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">template</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> T</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> HeapSort(T a[],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> size)<br><img id=Codehighlighter1_577_727_Open_Image onclick="this.style.display='none'; Codehighlighter1_577_727_Open_Text.style.display='none'; Codehighlighter1_577_727_Closed_Image.style.display='inline'; Codehighlighter1_577_727_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_577_727_Closed_Image onclick="this.style.display='none'; Codehighlighter1_577_727_Closed_Text.style.display='none'; Codehighlighter1_577_727_Open_Image.style.display='inline'; Codehighlighter1_577_727_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_577_727_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_577_727_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    Build_Max_Heap(a,size);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">size</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br><img id=Codehighlighter1_634_725_Open_Image onclick="this.style.display='none'; Codehighlighter1_634_725_Open_Text.style.display='none'; Codehighlighter1_634_725_Closed_Image.style.display='inline'; Codehighlighter1_634_725_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_634_725_Closed_Image onclick="this.style.display='none'; Codehighlighter1_634_725_Closed_Text.style.display='none'; Codehighlighter1_634_725_Open_Image.style.display='inline'; Codehighlighter1_634_725_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_634_725_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_634_725_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        swap(a[i],a[</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">]);       </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">灝嗘渶澶ф暟鎹㈠埌鏁扮粍鏈熬<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">show(a,size);</span><span style="COLOR: #008000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        size</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        Max_Heap(a,</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,size);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">template</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> T</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> show(T a[],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> size)<br><img id=Codehighlighter1_774_851_Open_Image onclick="this.style.display='none'; Codehighlighter1_774_851_Open_Text.style.display='none'; Codehighlighter1_774_851_Closed_Image.style.display='inline'; Codehighlighter1_774_851_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_774_851_Closed_Image onclick="this.style.display='none'; Codehighlighter1_774_851_Closed_Text.style.display='none'; Codehighlighter1_774_851_Open_Image.style.display='inline'; Codehighlighter1_774_851_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_774_851_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_774_851_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">鎺掑簭鍚庣粨鏋滀負</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">size;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br><img id=Codehighlighter1_826_849_Open_Image onclick="this.style.display='none'; Codehighlighter1_826_849_Open_Text.style.display='none'; Codehighlighter1_826_849_Closed_Image.style.display='inline'; Codehighlighter1_826_849_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_826_849_Closed_Image onclick="this.style.display='none'; Codehighlighter1_826_849_Closed_Text.style.display='none'; Codehighlighter1_826_849_Open_Image.style.display='inline'; Codehighlighter1_826_849_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_826_849_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_826_849_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">a[i]</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br><img id=Codehighlighter1_865_1068_Open_Image onclick="this.style.display='none'; Codehighlighter1_865_1068_Open_Text.style.display='none'; Codehighlighter1_865_1068_Closed_Image.style.display='inline'; Codehighlighter1_865_1068_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_865_1068_Closed_Image onclick="this.style.display='none'; Codehighlighter1_865_1068_Closed_Text.style.display='none'; Codehighlighter1_865_1068_Open_Image.style.display='inline'; Codehighlighter1_865_1068_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_865_1068_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_865_1068_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> num;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">num;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> input </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">[num];<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">num;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br><img id=Codehighlighter1_944_964_Open_Image onclick="this.style.display='none'; Codehighlighter1_944_964_Open_Text.style.display='none'; Codehighlighter1_944_964_Closed_Image.style.display='inline'; Codehighlighter1_944_964_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_944_964_Closed_Image onclick="this.style.display='none'; Codehighlighter1_944_964_Closed_Text.style.display='none'; Codehighlighter1_944_964_Open_Image.style.display='inline'; Codehighlighter1_944_964_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_944_964_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_944_964_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">input[i];<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    Build_Max_Heap(input,num);     </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">寤虹珛鏈澶у爢</span><span style="COLOR: #008000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    HeapSort(input,num);           </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鍫嗘帓搴?/span><span style="COLOR: #008000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    show(input,num);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span></div> <img src ="http://www.shnenglu.com/hunter/aggbug/109145.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/hunter/" target="_blank">hunter</a> 2010-03-07 22:08 <a href="http://www.shnenglu.com/hunter/archive/2010/03/07/109145.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>澶ф浜嗚Вcin錛宑in.getline錛宑in.clear錛宑in.ignore錛宑in.get()鐨勭敤娉?/title><link>http://www.shnenglu.com/hunter/archive/2008/11/28/68060.html</link><dc:creator>hunter</dc:creator><author>hunter</author><pubDate>Fri, 28 Nov 2008 05:24:00 GMT</pubDate><guid>http://www.shnenglu.com/hunter/archive/2008/11/28/68060.html</guid><wfw:comment>http://www.shnenglu.com/hunter/comments/68060.html</wfw:comment><comments>http://www.shnenglu.com/hunter/archive/2008/11/28/68060.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/hunter/comments/commentRss/68060.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/hunter/services/trackbacks/68060.html</trackback:ping><description><![CDATA[<h4 style="MARGIN-BOTTOM: 0px"><font color=#000000><span style="FONT-SIZE: 10pt"><font face="Times New Roman"> <p><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">cin.getline()</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>鏂規(guī)硶榪炵畫鍦頒粠鐢ㄦ埛緇堢鎺ュ彈瀛楃錛屽茍灝嗗瓧絎﹀瓨鍏ュ瓧絎﹀瀷鏁扮粍</font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">message</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>涓紝鐩村埌杈撳叆浜嗭紙</font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">maxchars</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>錛?/font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">1</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>錛変釜瀛楃錛堢</font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">maxchars</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>涓瓧絎︾敤鏉ュ瓨鍌ㄥ瓧絎︿覆緇撳熬鐨?/font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">NULL</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>瀛楃</font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">'\0')</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>鎴栬呮帴鍙楀埌浜嗗洖杞︿負姝紝榪欑粓绔敭鍏ュ洖杞﹂敭浜х敓涓涓崲琛?/font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">'\n'</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>錛屽畠琚?/font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">cin.getline()</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>璁や負鏄杈撳叆緇撳熬銆?/font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">cin.getline()</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>鑾峰緱鐨勫瓧絎?/font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">(</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>闄や簡鎹㈣絎﹀</font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">)</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>琚瓨鍌ㄥ埌</font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">message</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>鏁扮粍涓傚湪榪斿洖涔嬪墠錛?/font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">cin.getline</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>錛堬級鍑芥暟鍦ㄥ瓨鍌ㄧ殑榪欎簺瀛楃鍚庨潰娣誨姞涓涓?/font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">NULL</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>瀛楃</font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">'\0'</span><font face=瀹嬩綋><span style="FONT-SIZE: 9pt; COLOR: black">銆?/span><span lang=EN-US style="FONT-SIZE: 9pt"></span></font> <p><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">Cin.ignore</span><font face=瀹嬩綋><span style="FONT-SIZE: 9pt; COLOR: black">錛堬級鏂規(guī)硶</span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333">cin.ignore(   5,   'c'   )   </span><span style="FONT-SIZE: 9pt; COLOR: #333333">鐨勬槸浠庤緭鍏ユ祦錛?span lang=EN-US>cin</span>錛変腑鎻愬彇瀛楃錛屾彁鍙栫殑瀛楃琚拷鐣ワ紙<span lang=EN-US>ignore</span>錛夛紝涓嶈浣跨敤銆傛瘡鎶涘純涓涓瓧絎︼紝瀹冮兘瑕佽鏁板拰姣旇緝瀛楃錛氬鏋滆鏁板艱揪鍒?span lang=EN-US>5</span>鎴栬呰鎶涘純鐨勫瓧絎︽槸<span lang=EN-US>'c'</span>錛屽垯<span lang=EN-US>cin.ignore()   </span>鍑芥暟鎵ц緇堟錛涘惁鍒欙紝瀹冪戶緇瓑寰呫?span lang=EN-US>  </span>瀹冪殑涓涓父鐢ㄥ姛鑳藉氨鏄敤鏉ユ竻闄や互鍥炶濺緇撴潫鐨勮緭鍏ョ紦鍐插尯鐨勫唴瀹癸紝娑堥櫎涓婁竴嬈¤緭鍏ュ涓嬩竴嬈¤緭鍏ョ殑褰卞搷銆傛瘮濡傚彲浠ヨ繖涔堢敤錛?span lang=EN-US>cin.ignore(   1024,   '\n'   );</span>錛岄氬父鎶婄涓涓弬鏁拌緗緱瓚沖澶э紝榪欐牱瀹為檯涓婃繪槸鍙湁絎簩涓弬鏁?span lang=EN-US>   '\n'   </span>璧蜂綔鐢紝鎵浠ヨ繖涓鍙ュ氨鏄妸鍥炶濺錛堝寘鎷洖杞︼級涔嬪墠鐨勬墍浠ュ瓧絎︿粠杈撳叆緙撳啿錛堟祦錛変腑娓呴櫎鍑哄幓銆?/span><span lang=EN-US style="FONT-SIZE: 9pt"></span></font> <p><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">Cin.clear</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>鐢ㄦ硶濡傛灉杈撳叆鍙戠敓閿欒鍙戠敓錛岄偅涔堟祦鐘舵佹棦琚爣璁頒負閿欒錛屼綘蹇呴』娓呴櫎榪欎簺閿欒鐘舵侊紝浠ヤ嬌浣犵殑紼嬪簭鑳芥紜傚綋鍦扮戶緇繍琛屻傝娓呴櫎閿欒鐘舵侊紝闇浣跨敤</font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">clear()</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>鍑芥暟銆傛鍑芥暟甯︿竴涓弬鏁幫紝瀹冩槸浣犲皢瑕佽涓哄綋鍓嶇姸鎬佺殑鏍囧織鍊箋傦紝鍙灝?/font></span><span lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Times New Roman'">ios::goodbit</span><span style="FONT-SIZE: 9pt; COLOR: black"><font face=瀹嬩綋>浣滀負瀹炲弬</font></span><span lang=EN-US style="FONT-SIZE: 9pt"></span></font></span></font></h4> </p> <img src ="http://www.shnenglu.com/hunter/aggbug/68060.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/hunter/" target="_blank">hunter</a> 2008-11-28 13:24 <a href="http://www.shnenglu.com/hunter/archive/2008/11/28/68060.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍚堝茍鎺掑簭http://www.shnenglu.com/hunter/archive/2008/11/25/67846.htmlhunterhunterTue, 25 Nov 2008 13:03:00 GMThttp://www.shnenglu.com/hunter/archive/2008/11/25/67846.htmlhttp://www.shnenglu.com/hunter/comments/67846.htmlhttp://www.shnenglu.com/hunter/archive/2008/11/25/67846.html#Feedback0http://www.shnenglu.com/hunter/comments/commentRss/67846.htmlhttp://www.shnenglu.com/hunter/services/trackbacks/67846.html
鍚堝茍榪囩▼涓殑鍙橀噺瀹規(guī)槗鎼為敊錛岀壒鍒笉鑳藉拷鐣ュ悎騫惰繃紼嬩腑鏁扮粍杈圭晫鐨勬敼鍙橈紒錛侊紒
#include <iostream>
#include 
<string>
#include 
<vector>
#include 
<cmath>
using namespace std;

void Merge(int a[],int p,int k,int q)
{
   
int num1=k-p+1;
   
int num2=q-k;
   
int i;
   
int* b1=new int[num1+1];
   
int* b2=new int[num2+1];
   
for (i=0;i<num1;i++)
   
{
       b1[i]
=a[p+i];
   }

   b1[i]
=9999;
   
for (i=0;i<num2;i++)
   
{
       b2[i]
=a[k+i+1];
   }

   b2[i]
=9999;
   
int j=0;i=0;
   
for(int kk=p;kk<=q;kk++)    //娉ㄦ剰錛侊紒錛?br>   {
       
if (b1[i]<=b2[j])
           a[kk]
=b1[i++];
       
else
           a[kk]
=b2[j++];
   }

   delete [] b1;
   delete [] b2;
}

void MergeSort(int a[],int p,int q)
{
   
if (p<q)
   
{
       
int k=(p+q)/2;
       MergeSort(a,p,k);
       MergeSort(a,k
+1,q);
       Merge(a,p,k,q);
   }

}

int main()
{
   
int n;
   scanf(
"%d",&n);
   
int* input=new int[n];
   
for (int i=0;i<n;i++)
   
{
       scanf(
"%d",&input[i]);
   }

   MergeSort(input,
0,n-1);
   
for (int i=0;i<n;i++)
   
{
       printf(
"%d ",input[i]);
   }

   delete [] input;
}




hunter 2008-11-25 21:03 鍙戣〃璇勮
]]>
浜屽弶鏍?wèi)瀹炰?/title><link>http://www.shnenglu.com/hunter/archive/2008/11/22/67579.html</link><dc:creator>hunter</dc:creator><author>hunter</author><pubDate>Sat, 22 Nov 2008 05:52:00 GMT</pubDate><guid>http://www.shnenglu.com/hunter/archive/2008/11/22/67579.html</guid><wfw:comment>http://www.shnenglu.com/hunter/comments/67579.html</wfw:comment><comments>http://www.shnenglu.com/hunter/archive/2008/11/22/67579.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/hunter/comments/commentRss/67579.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/hunter/services/trackbacks/67579.html</trackback:ping><description><![CDATA[     鎽樿: 甯悓瀛﹀濡瑰紕鐨勪綔涓氥傘傘備互鍚庡彲浠ュ弬鑰?#include <iostream>#include <vector>#include <string>#include <math.h>#include <iomanip>#include <stdlib.h>#includ...  <a href='http://www.shnenglu.com/hunter/archive/2008/11/22/67579.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/hunter/aggbug/67579.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/hunter/" target="_blank">hunter</a> 2008-11-22 13:52 <a href="http://www.shnenglu.com/hunter/archive/2008/11/22/67579.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>浜屽弶鏍?wèi)鍓嶅簭銆佷腑搴忋佸悗搴忎笁縐嶉亶鍘嗙殑闈為掑綊綆楁硶http://www.shnenglu.com/hunter/archive/2008/11/22/67540.htmlhunterhunterFri, 21 Nov 2008 16:04:00 GMThttp://www.shnenglu.com/hunter/archive/2008/11/22/67540.htmlhttp://www.shnenglu.com/hunter/comments/67540.htmlhttp://www.shnenglu.com/hunter/archive/2008/11/22/67540.html#Feedback0http://www.shnenglu.com/hunter/comments/commentRss/67540.htmlhttp://www.shnenglu.com/hunter/services/trackbacks/67540.html1.鍏堝簭閬嶅巻闈為掑綊綆楁硶
void PreOrderUnrec(Bitree *t)
{
    Stack s;
    StackInit(s);
    Bitree *p=t;
   
    while (p!=NULL || !StackEmpty(s))
    {
        while (p!=NULL)             //閬嶅巻宸﹀瓙鏍?br>        {
            visite(p->data);
            push(s,p);
            p=p->lchild;  
        }
        
        if (!StackEmpty(s))         //閫氳繃涓嬩竴嬈″驚鐜腑鐨勫唴宓寃hile瀹炵幇鍙沖瓙鏍?wèi)閬嶅?br>        {
            p=pop(s);
            p=p->rchild;        
        }//endif
               
    }//endwhile 
}

2.涓簭閬嶅巻闈為掑綊綆楁硶
void InOrderUnrec(Bitree *t)
{
    Stack s;
    StackInit(s);
    Bitree *p=t;

    while (p!=NULL || !StackEmpty(s))
    {
        while (p!=NULL)             //閬嶅巻宸﹀瓙鏍?br>        {
            push(s,p);
            p=p->lchild;
        }
        
        if (!StackEmpty(s))
        {
            p=pop(s);
            visite(p->data);        //璁塊棶鏍圭粨鐐?br>            p=p->rchild;            //閫氳繃涓嬩竴嬈″驚鐜疄鐜板彸瀛愭爲(wèi)閬嶅巻
        }//endif   
   
    }//endwhile
}

3.鍚庡簭閬嶅巻闈為掑綊綆楁硶
typedef enum{L,R} tagtype;
typedef struct
{
    Bitree ptr;
    tagtype tag;
}stacknode;

typedef struct
{
    stacknode Elem[maxsize];
    int top;
}SqStack;

void PostOrderUnrec(Bitree t)
{
    SqStack s;
    stacknode x;
    StackInit(s);
    p=t;
   
    do
    {
        while (p!=null)        //閬嶅巻宸﹀瓙鏍?br>        {
            x.ptr = p;
            x.tag = L;         //鏍囪涓哄乏瀛愭爲(wèi)
            push(s,x);
            p=p->lchild;
        }
   
        while (!StackEmpty(s) && s.Elem[s.top].tag==R)  
        {
            x = pop(s);
            p = x.ptr;
            visite(p->data);   //tag涓篟錛岃〃紺哄彸瀛愭爲(wèi)璁塊棶瀹屾瘯錛屾晠璁塊棶鏍圭粨鐐?nbsp;     
        }
        
        if (!StackEmpty(s))
        {
            s.Elem[s.top].tag =R;     //閬嶅巻鍙沖瓙鏍?br>            p=s.Elem[s.top].ptr->rchild;        
        }   
    }while (!StackEmpty(s));
}//PostOrderUnrec

浜屻傚墠搴忔渶綆媧佺畻娉?br>void PreOrderUnrec(Bitree *t)
{
   Bitree *p;
   Stack s;
   s.push(t);

   while (!s.IsEmpty())
   {
      s.pop(p);
      visit(p->data);
      if (p->rchild != NULL) s.push(p->rchild);
      if (p->lchild != NULL) s.push(p->lchild);
   }
}


涓夈傚悗搴忕畻娉曚箣浜?/strong>
void BT_PostOrderNoRec(pTreeT root)
{
stack<treeT *> s;
pTreeT pre=NULL;

while ((NULL != root) || !s.empty())
{
if (NULL != root)
{
s.push(root);
root = root->left;
}
else
{
root = s.top();
if (root->right!=NULL && pre!=root->right){
root=root->right;
}
else{
root=pre=s.top();
visit(root);
s.pop();
root=NULL;
}
}
}
}



hunter 2008-11-22 00:04 鍙戣〃璇勮
]]>
瀛楀吀鏍?wèi)鍘熺悊锛堣浆锛?/title><link>http://www.shnenglu.com/hunter/archive/2008/11/16/67039.html</link><dc:creator>hunter</dc:creator><author>hunter</author><pubDate>Sun, 16 Nov 2008 03:42:00 GMT</pubDate><guid>http://www.shnenglu.com/hunter/archive/2008/11/16/67039.html</guid><wfw:comment>http://www.shnenglu.com/hunter/comments/67039.html</wfw:comment><comments>http://www.shnenglu.com/hunter/archive/2008/11/16/67039.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/hunter/comments/commentRss/67039.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/hunter/services/trackbacks/67039.html</trackback:ping><description><![CDATA[<p>Trie鏍?wèi)灏辨槸瀛楀吀鏍?wèi)錛屽叾鏍稿績鎬濇兂灝辨槸絀洪棿鎹㈡椂闂淬?/p> <p><br>涓句釜綆鍗曠殑渚嬪瓙銆?/p> <p><br>緇欎綘100000涓暱搴︿笉瓚呰繃10鐨勫崟璇嶃傚浜庢瘡涓涓崟璇嶏紝鎴戜滑瑕佸垽鏂粬鍑烘病鍑虹幇榪囷紝濡傛灉鍑虹幇浜嗭紝絎竴嬈″嚭鐜扮鍑犱釜浣嶇疆銆?br>榪欓褰撶劧鍙互鐢╤ash鏉ワ紝浣嗘槸鎴戣浠嬬粛鐨勬槸trie鏍?wèi)銆傚湪鏌愪簺鏂歸潰瀹冪殑鐢ㄩ旀洿澶с傛瘮濡傝瀵逛簬鏌愪竴涓崟璇嶏紝鎴戣璇㈤棶瀹冪殑鍓嶇紑鏄惁鍑虹幇榪囥傝繖鏍穐ash灝變笉濂芥悶浜嗭紝鑰岀敤trie榪樻槸寰堢畝鍗曘?br>鐜板湪鍥炲埌渚嬪瓙涓紝濡傛灉鎴戜滑鐢ㄦ渶鍌?cè)潥勬栆?guī)硶錛屽浜庢瘡涓涓崟璇嶏紝鎴戜滑閮借鍘繪煡鎵懼畠鍓嶉潰鐨勫崟璇嶄腑鏄惁鏈夊畠銆傞偅涔堣繖涓畻娉曠殑澶嶆潅搴﹀氨鏄疧(n^2)銆傛樉鐒跺浜?00000鐨勮寖鍥撮毦浠ユ帴鍙椼傜幇鍦ㄦ垜浠崲涓濊礬鎯熾傚亣璁炬垜瑕佹煡璇㈢殑鍗曡瘝鏄痑bcd錛岄偅涔堝湪浠栧墠闈㈢殑鍗曡瘝涓紝浠錛宑錛宒錛宖涔嬬被寮澶寸殑鎴戞樉鐒朵笉蹇呰冭檻銆傝屽彧瑕佹壘浠寮澶寸殑涓槸鍚﹀瓨鍦╝bcd灝卞彲浠ヤ簡銆傚悓鏍風(fēng)殑錛屽湪浠寮澶翠腑鐨勫崟璇嶄腑錛屾垜浠彧瑕佽冭檻浠浣滀負絎簩涓瓧姣嶇殑……榪欐牱涓涓爲(wèi)鐨勬ā鍨嬪氨娓愭笎娓呮櫚浜?#8230;…<br>鍋囪鏈塨錛宎bc錛宎bd錛宐cd錛宎bcd錛宔fg錛宧ii榪?涓崟璇嶏紝鎴戜滑鏋勫緩鐨勬爲(wèi)灝辨槸榪欐牱鐨勩?br><img height=325 alt="" src="http://www.shnenglu.com/images/cppblog_com/hunter/z200777202049.jpg" width=388 border=0><br>瀵逛簬姣忎竴涓妭鐐癸紝浠庢牴閬嶅巻鍒頒粬鐨勮繃紼嬪氨鏄竴涓崟璇嶏紝濡傛灉榪欎釜鑺傜偣琚爣璁頒負綰㈣壊錛屽氨琛ㄧず榪欎釜鍗曡瘝瀛樺湪錛屽惁鍒欎笉瀛樺湪銆?br>閭d箞錛屽浜庝竴涓崟璇嶏紝鎴戝彧瑕侀『鐫浠栦粠璺熻蛋鍒板搴旂殑鑺傜偣錛屽啀鐪嬭繖涓妭鐐規(guī)槸鍚﹁鏍囪涓虹孩鑹插氨鍙互鐭ラ亾瀹冩槸鍚﹀嚭鐜拌繃浜嗐傛妸榪欎釜鑺傜偣鏍囪涓虹孩鑹詫紝灝辯浉褰撲簬鎻掑叆浜嗚繖涓崟璇嶃?br>榪欐牱涓鏉ユ垜浠闂拰鎻掑叆鍙互涓璧峰畬鎴愶紝鎵鐢ㄦ椂闂翠粎浠呬負鍗曡瘝闀垮害錛屽湪榪欎竴涓牱渚嬶紝渚挎槸10銆?br>鎴戜滑鍙互鐪嬪埌錛宼rie鏍?wèi)姣忎竴灞傜殑鑺傜偣鏁版槸26^i綰у埆鐨勩傛墍浠ヤ負浜嗚妭鐪佺┖闂淬傛垜浠敤鍔ㄦ侀摼琛紝鎴栬呯敤鏁扮粍鏉ユā鎷熷姩鎬併傜┖闂寸殑鑺辮垂錛屼笉浼氳秴榪囧崟璇嶆暟×鍗曡瘝闀垮害銆?/p> <p> </p> <p>緇欏嚭涓涓敤綾誨皝瑁呯殑瀛楀吀鏍?wèi)浠g爜锛屽巹銆傘傘傚仛ACM鐨勬ā鏉跨敤鍙︿竴涓傘傚簲璇ユ斁鍦ㄤ簡“ACM妯℃澘”鏂囦歡澶逛笅浜嗐傘傘?/p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cstdio</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cstring</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> num_chars </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">26</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img id=Codehighlighter1_119_472_Open_Image onclick="this.style.display='none'; Codehighlighter1_119_472_Open_Text.style.display='none'; Codehighlighter1_119_472_Closed_Image.style.display='inline'; Codehighlighter1_119_472_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_119_472_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_119_472_Closed_Text.style.display='none'; Codehighlighter1_119_472_Open_Image.style.display='inline'; Codehighlighter1_119_472_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> Trie </span><span id=Codehighlighter1_119_472_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_119_472_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br><img id=Codehighlighter1_152_153_Open_Image onclick="this.style.display='none'; Codehighlighter1_152_153_Open_Text.style.display='none'; Codehighlighter1_152_153_Closed_Image.style.display='inline'; Codehighlighter1_152_153_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_152_153_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_152_153_Closed_Text.style.display='none'; Codehighlighter1_152_153_Open_Image.style.display='inline'; Codehighlighter1_152_153_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>      Trie():root(NULL)</span><span id=Codehighlighter1_152_153_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_152_153_Open_Text><span style="COLOR: #000000">{}</span></span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      Trie(Trie</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000"> tr);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>     </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> search(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> word, </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> entry ) </span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>     </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> insert(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> word, </span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> entry);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>     </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> remove(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> word, </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> entry);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000">:<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>     </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> Trie_node<br><img id=Codehighlighter1_372_463_Open_Image onclick="this.style.display='none'; Codehighlighter1_372_463_Open_Text.style.display='none'; Codehighlighter1_372_463_Closed_Image.style.display='inline'; Codehighlighter1_372_463_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_372_463_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_372_463_Closed_Text.style.display='none'; Codehighlighter1_372_463_Open_Image.style.display='inline'; Codehighlighter1_372_463_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>     </span><span id=Codehighlighter1_372_463_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_372_463_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>         </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> data;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>          Trie_node</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> branch[num_chars];<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>          Trie_node();<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>     }</span></span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> root;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>Trie::Trie_node::Trie_node() <br><img id=Codehighlighter1_505_591_Open_Image onclick="this.style.display='none'; Codehighlighter1_505_591_Open_Text.style.display='none'; Codehighlighter1_505_591_Closed_Image.style.display='inline'; Codehighlighter1_505_591_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_505_591_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_505_591_Closed_Text.style.display='none'; Codehighlighter1_505_591_Open_Image.style.display='inline'; Codehighlighter1_505_591_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_505_591_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_505_591_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      data </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> NULL;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">num_chars; </span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">i) <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>          branch[i] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> NULL;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> Trie::search(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> word, </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> entry ) </span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> <br><img id=Codehighlighter1_650_1191_Open_Image onclick="this.style.display='none'; Codehighlighter1_650_1191_Open_Text.style.display='none'; Codehighlighter1_650_1191_Closed_Image.style.display='inline'; Codehighlighter1_650_1191_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_650_1191_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_650_1191_Closed_Text.style.display='none'; Codehighlighter1_650_1191_Open_Image.style.display='inline'; Codehighlighter1_650_1191_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_650_1191_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_650_1191_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> position </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> char_code;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>     Trie_node </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">location </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> root;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">( location</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">NULL </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> ) <br><img id=Codehighlighter1_772_1047_Open_Image onclick="this.style.display='none'; Codehighlighter1_772_1047_Open_Text.style.display='none'; Codehighlighter1_772_1047_Closed_Image.style.display='inline'; Codehighlighter1_772_1047_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_772_1047_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_772_1047_Closed_Text.style.display='none'; Codehighlighter1_772_1047_Open_Image.style.display='inline'; Codehighlighter1_772_1047_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_772_1047_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_772_1047_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">Z</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">) <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>              char_code </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">z</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">) <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>              char_code </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>         location </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> location</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">branch[char_code];<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>         position</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>         word</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> ( location </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> NULL </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> location</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">data </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> NULL ) <br><img id=Codehighlighter1_1108_1170_Open_Image onclick="this.style.display='none'; Codehighlighter1_1108_1170_Open_Text.style.display='none'; Codehighlighter1_1108_1170_Closed_Image.style.display='inline'; Codehighlighter1_1108_1170_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1108_1170_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1108_1170_Closed_Text.style.display='none'; Codehighlighter1_1108_1170_Open_Image.style.display='inline'; Codehighlighter1_1108_1170_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_1108_1170_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1108_1170_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        strcpy(entry,location</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">data);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> Trie::insert(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> word, </span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> entry) <br><img id=Codehighlighter1_1248_2003_Open_Image onclick="this.style.display='none'; Codehighlighter1_1248_2003_Open_Text.style.display='none'; Codehighlighter1_1248_2003_Closed_Image.style.display='inline'; Codehighlighter1_1248_2003_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_1248_2003_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1248_2003_Closed_Text.style.display='none'; Codehighlighter1_1248_2003_Open_Image.style.display='inline'; Codehighlighter1_1248_2003_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_1248_2003_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1248_2003_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> result </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, position </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> ( root </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> NULL ) root </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Trie_node;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> char_code;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      Trie_node </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">location </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> root;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">( location</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">NULL </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> )<br><img id=Codehighlighter1_1428_1818_Open_Image onclick="this.style.display='none'; Codehighlighter1_1428_1818_Open_Text.style.display='none'; Codehighlighter1_1428_1818_Closed_Image.style.display='inline'; Codehighlighter1_1428_1818_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1428_1818_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1428_1818_Closed_Text.style.display='none'; Codehighlighter1_1428_1818_Open_Image.style.display='inline'; Codehighlighter1_1428_1818_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_1428_1818_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1428_1818_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">Z</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">) <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>              char_code </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">z</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">) <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>              char_code </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">word</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">( location</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">branch[char_code] </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> NULL ) <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>              location</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">branch[char_code] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Trie_node;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>          location </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> location</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">branch[char_code];<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>          position</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>          word</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (location</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">data </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> NULL)<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>          result </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img id=Codehighlighter1_1883_1982_Open_Image onclick="this.style.display='none'; Codehighlighter1_1883_1982_Open_Text.style.display='none'; Codehighlighter1_1883_1982_Closed_Image.style.display='inline'; Codehighlighter1_1883_1982_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1883_1982_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1883_1982_Closed_Text.style.display='none'; Codehighlighter1_1883_1982_Open_Image.style.display='inline'; Codehighlighter1_1883_1982_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span id=Codehighlighter1_1883_1982_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1883_1982_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>          location</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">data </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">[strlen(entry)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">];<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        strcpy(location</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">data, entry);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> result;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br><img id=Codehighlighter1_2016_2731_Open_Image onclick="this.style.display='none'; Codehighlighter1_2016_2731_Open_Text.style.display='none'; Codehighlighter1_2016_2731_Closed_Image.style.display='inline'; Codehighlighter1_2016_2731_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_2016_2731_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2016_2731_Closed_Text.style.display='none'; Codehighlighter1_2016_2731_Open_Image.style.display='inline'; Codehighlighter1_2016_2731_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_2016_2731_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_2016_2731_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      Trie t;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> entry[</span><span style="COLOR: #000000">100</span><span style="COLOR: #000000">];<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      t.insert(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">aa</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">DET</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      t.insert(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abacus</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">NOUN</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      t.insert(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abalone</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">NOUN</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      t.insert(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abandon</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">VERB</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      t.insert(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abandoned</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ADJ</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      t.insert(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abashed</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ADJ</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      t.insert(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abate</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">VERB</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      t.insert(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">this</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">PRON</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (t.search(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">this</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, entry))<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">'this' was found. pos: </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">entry</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (t.search(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abate</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, entry))<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">'abate' is found. pos: </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">entry</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (t.search(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">baby</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, entry))<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">'baby' is found. pos: </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">entry</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">'baby' does not exist at all!</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (t.search(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">aa</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, entry))<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">'aa was found. pos: </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">entry</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span></div> <br>PS:瀹炵幇鏂規(guī)硶<a >http://met.fzu.edu.cn/eduonline/web/web/resources/articleContent.asp?id=346</a> <img src ="http://www.shnenglu.com/hunter/aggbug/67039.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/hunter/" target="_blank">hunter</a> 2008-11-16 11:42 <a href="http://www.shnenglu.com/hunter/archive/2008/11/16/67039.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>涓冪qsort鎺掑簭鏂規(guī)硶http://www.shnenglu.com/hunter/archive/2008/11/15/67018.htmlhunterhunterSat, 15 Nov 2008 13:32:00 GMThttp://www.shnenglu.com/hunter/archive/2008/11/15/67018.htmlhttp://www.shnenglu.com/hunter/comments/67018.htmlhttp://www.shnenglu.com/hunter/archive/2008/11/15/67018.html#Feedback0http://www.shnenglu.com/hunter/comments/commentRss/67018.htmlhttp://www.shnenglu.com/hunter/services/trackbacks/67018.html涓銆佸int綾誨瀷鏁扮粍鎺掑簭
紼嬪簭浠g爜 紼嬪簭浠g爜
int num[100];
Sample:
int cmp ( const void *a , const void *b )
{
     return *(int *)a - *(int *)b;
}
qsort(num,100,sizeof(num[0]),cmp);

浜屻佸char綾誨瀷鏁扮粍鎺掑簭錛堝悓int綾誨瀷錛?br>紼嬪簭浠g爜 紼嬪簭浠g爜
char word[100];
Sample:
int cmp( const void *a , const void *b )
{
    return *(char *)a - *(char*)b;
}
qsort(word,100,sizeof(word[0]),cmp)

涓夈佸double綾誨瀷鏁扮粍鎺掑簭錛堢壒鍒娉ㄦ剰錛?br>紼嬪簭浠g爜 紼嬪簭浠g爜
double in[100];
int cmp( const void *a , const void *b )
{
    return *(double *)a > *(double *)b ? 1 : -1;
} qsort(in,100,sizeof(in[0]),cmp)錛?br> 
鍥涖佸緇撴瀯浣撲竴綰ф帓搴?
紼嬪簭浠g爜 紼嬪簭浠g爜
struct In {
 double data;
 int other;
}s[100]
//鎸夌収data鐨勫間粠灝忓埌澶у皢緇撴瀯浣撴帓搴?鍏充簬緇撴瀯浣撳唴鐨勬帓搴忓叧閿暟鎹甦ata鐨勭被鍨嬪彲浠ュ緢澶氱錛?br>鍙傝冧笂闈㈢殑渚嬪瓙鍐?
int cmp( const void *a ,const void *b)
{
     return (*(In *)a).data > (*(In *)b).data ? 1 : -1;
}
qsort(s,100,sizeof(s[0]),cmp);

浜斻佸緇撴瀯浣撲簩綰ф帓搴?
紼嬪簭浠g爜 紼嬪簭浠g爜
struct In {
   int x; int y;
}s[100];
//鎸夌収x浠庡皬鍒板ぇ鎺掑簭錛屽綋x鐩哥瓑鏃舵寜鐓浠庡ぇ鍒板皬鎺掑簭
int cmp( const void *a , const void *b )
{
    struct In *c = (In *)a;
    struct In *d = (In *)b;
    if(c->x != d->x) return c->x - d->x;
    else return d->y - c->y;
}
qsort(s,100,sizeof(s[0]),cmp);

鍏佸瀛楃涓茶繘琛屾帓搴?
紼嬪簭浠g爜 紼嬪簭浠g爜
struct In {
   int data; char str[100];
}s[100];
//鎸夌収緇撴瀯浣撲腑瀛楃涓瞫tr鐨勫瓧鍏擱『搴忔帓搴?
int cmp ( const void *a , const void *b )
{
    return strcmp( (*(In *)a)->str , (*(In *)b)->str );
}
qsort(s,100,sizeof(s[0]),cmp);

涓冦佽綆楀嚑浣曚腑姹傚嚫鍖呯殑cmp
紼嬪簭浠g爜 紼嬪簭浠g爜
int cmp(const void *a,const void *b)
//閲嶇偣cmp鍑芥暟錛屾妸闄や簡1鐐瑰鐨勬墍鏈夌偣錛屾棆杞搴︽帓搴?
{
    struct point *c=(point *)a;
    struct point *d=(point *)b;
    if( calc(*c,*d,p[1]) < 0) return 1;
    else if( !calc(*c,*d,p[1])
   && dis(c->x,c->y,p[1].x,p[1].y) < dis(d->x,d->y,p[1].x,p[1].y))
   //濡傛灉鍦ㄤ竴鏉$洿綰夸笂錛屽垯鎶婅繙鐨勬斁鍦ㄥ墠闈?
   return 1; else return -1;
}
 
PS: 鍏朵腑鐨剄sort鍑芥暟鍖呭惈鍦?lt;stdlib.h>鐨勫ご鏂囦歡閲岋紝strcmp鍖呭惈鍦?lt;string.h>鐨勫ご鏂囦歡閲?

hunter 2008-11-15 21:32 鍙戣〃璇勮
]]>
12涓悆鎵句笉鍚岀殑鏅哄姏棰樿В棰樻濊礬http://www.shnenglu.com/hunter/archive/2008/11/14/66897.htmlhunterhunterFri, 14 Nov 2008 03:55:00 GMThttp://www.shnenglu.com/hunter/archive/2008/11/14/66897.htmlhttp://www.shnenglu.com/hunter/comments/66897.htmlhttp://www.shnenglu.com/hunter/archive/2008/11/14/66897.html#Feedback0http://www.shnenglu.com/hunter/comments/commentRss/66897.htmlhttp://www.shnenglu.com/hunter/services/trackbacks/66897.html2涓悆,澶у皬鍚?鍏朵腑涓涓噸閲忎笉鍚屻傜幇鏈変竴涓ぉ騫?瑕佺敤榪欎釜澶╁鉤縐?嬈℃壘鍑鴻繖涓笉鍚岄噸閲忕殑鐞?濡備綍縐?

灝嗘墍鏈夌悆緙栧彿涓?-12錛?br>絎竴姝ワ紝灝?-4鍙鋒斁宸﹁竟錛?-8鍙鋒斁鍙寵竟錛?br>        鑻ュ炬枩錛屽亣璁懼彸閲嶏紙宸﹂噸闆峰悓錛夛細
        絎簩姝0]錛屽皢2-4縐昏蛋錛?-8縐誨叆宸﹁竟錛?-11縐誨叆鍙寵竟錛?br>                鑻ヤ粛鍊炬枩錛屽垯涓嶅悓鐨勯偅涓負緙栧彿1鎴?鍙鳳細
                        絎笁姝0][0]錛屽皢1鍙蜂笌2鍙鋒瘮杈冿紝鑻ョ浉絳夛紝鍒?鍙峰亸閲嶏紝鍙嶄箣錛?鍙風(fēng)悆鍋忚交錛?br>                鑻ヤ笉鍊炬枩錛屽垯涓嶅悓鐨勯偅涓湪緙栧彿2-4涓紝涓斿亸杞伙紱
                        絎笁姝0][1]錛屼換鍙?-4縐嶄袱鐞冨彲寰楃粨鏋滐紱
        鑻ヤ笉鍊炬枩錛屽垯涓嶅悓鐨勫湪9-12涓細
        絎簩姝1]錛岀Щ璧?-8鐞冿紝縐誨叆9-11鐞冿細
                鑻ュ炬枩錛屽亣璁懼彸閲嶏紙宸﹂噸闆峰悓錛夛細
                絎笁姝1][0]錛屼換鍙?-11縐嶄袱鐞冨彲寰楃粨鏋滐紱
                鑻ヤ笉鍊炬枩錛屽垯12鍙風(fēng)悆寮傚父錛?br>                絎笁姝1][1]錛屽皢12鍙風(fēng)悆涓庡叾瀹冧換鎰忕悆姣旇緝鍙煡鏄交鏄噸錛?/p>

hunter 2008-11-14 11:55 鍙戣〃璇勮
]]>
涓閬撶綉鏄撶殑絎旇瘯棰?/title><link>http://www.shnenglu.com/hunter/archive/2008/11/11/66570.html</link><dc:creator>hunter</dc:creator><author>hunter</author><pubDate>Mon, 10 Nov 2008 16:25:00 GMT</pubDate><guid>http://www.shnenglu.com/hunter/archive/2008/11/11/66570.html</guid><wfw:comment>http://www.shnenglu.com/hunter/comments/66570.html</wfw:comment><comments>http://www.shnenglu.com/hunter/archive/2008/11/11/66570.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/hunter/comments/commentRss/66570.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/hunter/services/trackbacks/66570.html</trackback:ping><description><![CDATA[<p>涓涓狵浣嶇殑鏁癗 (K<=2000,N<=10^20)<br>鎵懼嚭涓涓瘮N澶т笖鏈鎺ヨ繎鐨勬暟錛岃繖涓暟鐨勬瘡浣嶄箣鍜屼笌N鐩稿悓<br>鐢ㄤ唬鐮佸疄鐜頒箣</p> <p>濡傦細<br>0050    鎵姹傛暟涓?104<br>112     鎵姹傛暟涓?21</p> <br>鎬葷畻鐪嬪埌涓棰樹細鍋氱殑 -_-|||<br>浠庡彸寰宸︽壂鎻忓嵆鍙紝鑰屼笖緇欏嚭鐨勪緥瀛愪篃寰堝吀鍨嬨?br>鑰冭檻闂鍏ㄩ潰涓浜涳紝娉ㄦ剰 823993 榪欐牱鐨勬儏鍐?<br><br><br>渚?3919999700<br>浠庡彸鍚戝乏鎵懼埌絎竴涓潪0 7,7-- ,騫朵笖鎶?縐誨埌鏈鍚?br>緇х畫鎵鍒?灝辯Щ鍒版渶鍚?鎵懼埌絎竴涓潪9 1, 1++<br>鏈鍚庡彉鎴?3920069999<br><br>榪樿鑰冭檻鍒板彧鏈変竴浣嶉潪闆跺鹼紝榪涗綅闂<br>濡?0-銆?08 <img src ="http://www.shnenglu.com/hunter/aggbug/66570.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/hunter/" target="_blank">hunter</a> 2008-11-11 00:25 <a href="http://www.shnenglu.com/hunter/archive/2008/11/11/66570.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <a href="http://www.shnenglu.com/">青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品</a> <div style="position:fixed;left:-9000px;top:-9000px;"><font id="pjuwb"></font><button id="pjuwb"><pre id="pjuwb"></pre></button><sub id="pjuwb"></sub><tbody id="pjuwb"><var id="pjuwb"><address id="pjuwb"></address></var></tbody><listing id="pjuwb"><label id="pjuwb"><strong id="pjuwb"></strong></label></listing><wbr id="pjuwb"><small id="pjuwb"><tbody id="pjuwb"></tbody></small></wbr><ins id="pjuwb"><xmp id="pjuwb"></xmp></ins><style id="pjuwb"></style><label id="pjuwb"><em id="pjuwb"><li id="pjuwb"></li></em></label><samp id="pjuwb"></samp><menu id="pjuwb"><input id="pjuwb"></input></menu><pre id="pjuwb"><tbody id="pjuwb"><tfoot id="pjuwb"><button id="pjuwb"></button></tfoot></tbody></pre><form id="pjuwb"></form><i id="pjuwb"><style id="pjuwb"><label id="pjuwb"><sup id="pjuwb"></sup></label></style></i><li id="pjuwb"><table id="pjuwb"><abbr id="pjuwb"></abbr></table></li><video id="pjuwb"></video><dfn id="pjuwb"></dfn><progress id="pjuwb"></progress><strong id="pjuwb"></strong><mark id="pjuwb"></mark><em id="pjuwb"></em><tbody id="pjuwb"><p id="pjuwb"><strike id="pjuwb"><acronym id="pjuwb"></acronym></strike></p></tbody><option id="pjuwb"></option><strike id="pjuwb"></strike><u id="pjuwb"></u><td id="pjuwb"><center id="pjuwb"><tr id="pjuwb"></tr></center></td><em id="pjuwb"><mark id="pjuwb"><em id="pjuwb"><tt id="pjuwb"></tt></em></mark></em><strong id="pjuwb"></strong><wbr id="pjuwb"></wbr><s id="pjuwb"></s><strong id="pjuwb"></strong><legend id="pjuwb"></legend><nav id="pjuwb"></nav><dl id="pjuwb"><th id="pjuwb"><dl id="pjuwb"></dl></th></dl><noframes id="pjuwb"><ins id="pjuwb"></ins></noframes><font id="pjuwb"></font><strike id="pjuwb"><i id="pjuwb"><style id="pjuwb"><label id="pjuwb"></label></style></i></strike><output id="pjuwb"></output><thead id="pjuwb"><pre id="pjuwb"></pre></thead><source id="pjuwb"></source><menuitem id="pjuwb"><wbr id="pjuwb"></wbr></menuitem><pre id="pjuwb"><span id="pjuwb"><pre id="pjuwb"><big id="pjuwb"></big></pre></span></pre><cite id="pjuwb"><fieldset id="pjuwb"><s id="pjuwb"><rt id="pjuwb"></rt></s></fieldset></cite><big id="pjuwb"><progress id="pjuwb"><big id="pjuwb"></big></progress></big><samp id="pjuwb"><delect id="pjuwb"></delect></samp><dl id="pjuwb"></dl><strike id="pjuwb"><nav id="pjuwb"><dl id="pjuwb"><strong id="pjuwb"></strong></dl></nav></strike><tbody id="pjuwb"><b id="pjuwb"><optgroup id="pjuwb"><rp id="pjuwb"></rp></optgroup></b></tbody><em id="pjuwb"></em><xmp id="pjuwb"><blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote></xmp> <i id="pjuwb"><abbr id="pjuwb"><i id="pjuwb"><abbr id="pjuwb"></abbr></i></abbr></i><center id="pjuwb"><acronym id="pjuwb"><center id="pjuwb"></center></acronym></center><pre id="pjuwb"></pre><ul id="pjuwb"><thead id="pjuwb"></thead></ul><blockquote id="pjuwb"><pre id="pjuwb"><sup id="pjuwb"></sup></pre></blockquote><acronym id="pjuwb"></acronym><big id="pjuwb"><s id="pjuwb"></s></big><th id="pjuwb"></th><th id="pjuwb"></th><tbody id="pjuwb"></tbody><thead id="pjuwb"><strike id="pjuwb"></strike></thead><th id="pjuwb"><dl id="pjuwb"><wbr id="pjuwb"></wbr></dl></th><dl id="pjuwb"><strong id="pjuwb"></strong></dl><abbr id="pjuwb"><noframes id="pjuwb"><noscript id="pjuwb"></noscript></noframes></abbr><td id="pjuwb"><ol id="pjuwb"></ol></td><li id="pjuwb"><noscript id="pjuwb"><abbr id="pjuwb"></abbr></noscript></li><small id="pjuwb"><bdo id="pjuwb"><nav id="pjuwb"></nav></bdo></small><style id="pjuwb"></style><optgroup id="pjuwb"><table id="pjuwb"></table></optgroup><center id="pjuwb"><tr id="pjuwb"><dfn id="pjuwb"></dfn></tr></center><th id="pjuwb"></th><u id="pjuwb"></u><tfoot id="pjuwb"><legend id="pjuwb"><i id="pjuwb"></i></legend></tfoot><mark id="pjuwb"></mark><meter id="pjuwb"></meter><nav id="pjuwb"></nav><acronym id="pjuwb"><pre id="pjuwb"><acronym id="pjuwb"><ul id="pjuwb"></ul></acronym></pre></acronym><acronym id="pjuwb"><pre id="pjuwb"><acronym id="pjuwb"><ul id="pjuwb"></ul></acronym></pre></acronym><nobr id="pjuwb"></nobr><sub id="pjuwb"><th id="pjuwb"><menuitem id="pjuwb"><wbr id="pjuwb"></wbr></menuitem></th></sub><thead id="pjuwb"><sub id="pjuwb"></sub></thead><ul id="pjuwb"><address id="pjuwb"><menuitem id="pjuwb"><meter id="pjuwb"></meter></menuitem></address></ul><dfn id="pjuwb"></dfn><pre id="pjuwb"></pre><input id="pjuwb"><cite id="pjuwb"><fieldset id="pjuwb"></fieldset></cite></input><u id="pjuwb"><form id="pjuwb"><u id="pjuwb"></u></form></u><kbd id="pjuwb"><em id="pjuwb"><mark id="pjuwb"></mark></em></kbd><tr id="pjuwb"></tr><del id="pjuwb"><form id="pjuwb"><address id="pjuwb"></address></form></del><tfoot id="pjuwb"><legend id="pjuwb"><ol id="pjuwb"><dl id="pjuwb"></dl></ol></legend></tfoot><menu id="pjuwb"><nobr id="pjuwb"><th id="pjuwb"><nobr id="pjuwb"></nobr></th></nobr></menu><fieldset id="pjuwb"></fieldset><pre id="pjuwb"><blockquote id="pjuwb"><samp id="pjuwb"></samp></blockquote></pre><xmp id="pjuwb"><sup id="pjuwb"><pre id="pjuwb"></pre></sup></xmp><span id="pjuwb"><progress id="pjuwb"></progress></span><font id="pjuwb"></font><var id="pjuwb"><abbr id="pjuwb"></abbr></var><strong id="pjuwb"><label id="pjuwb"><i id="pjuwb"><legend id="pjuwb"></legend></i></label></strong><tr id="pjuwb"><em id="pjuwb"><em id="pjuwb"><output id="pjuwb"></output></em></em></tr><thead id="pjuwb"><strike id="pjuwb"></strike></thead> <acronym id="pjuwb"></acronym><i id="pjuwb"></i><tt id="pjuwb"></tt><rt id="pjuwb"><source id="pjuwb"><rt id="pjuwb"></rt></source></rt><strike id="pjuwb"><acronym id="pjuwb"></acronym></strike><del id="pjuwb"></del><font id="pjuwb"><output id="pjuwb"><ins id="pjuwb"><output id="pjuwb"></output></ins></output></font><kbd id="pjuwb"><tr id="pjuwb"><kbd id="pjuwb"></kbd></tr></kbd><pre id="pjuwb"><sup id="pjuwb"><delect id="pjuwb"><samp id="pjuwb"></samp></delect></sup></pre><samp id="pjuwb"></samp><track id="pjuwb"></track><tr id="pjuwb"></tr><center id="pjuwb"></center><fieldset id="pjuwb"></fieldset><i id="pjuwb"></i><td id="pjuwb"></td><rt id="pjuwb"></rt><object id="pjuwb"></object><pre id="pjuwb"><progress id="pjuwb"><sub id="pjuwb"><thead id="pjuwb"></thead></sub></progress></pre><kbd id="pjuwb"><tr id="pjuwb"><option id="pjuwb"></option></tr></kbd><output id="pjuwb"><ins id="pjuwb"></ins></output><ol id="pjuwb"></ol><source id="pjuwb"></source><strong id="pjuwb"></strong><ruby id="pjuwb"></ruby><sub id="pjuwb"><meter id="pjuwb"><menuitem id="pjuwb"><meter id="pjuwb"></meter></menuitem></meter></sub><pre id="pjuwb"></pre><center id="pjuwb"></center><tr id="pjuwb"><tbody id="pjuwb"><xmp id="pjuwb"><dd id="pjuwb"></dd></xmp></tbody></tr><video id="pjuwb"></video><pre id="pjuwb"></pre><form id="pjuwb"><optgroup id="pjuwb"></optgroup></form><samp id="pjuwb"></samp><kbd id="pjuwb"></kbd><strong id="pjuwb"><option id="pjuwb"></option></strong><object id="pjuwb"></object><abbr id="pjuwb"><noframes id="pjuwb"><abbr id="pjuwb"></abbr></noframes></abbr><ul id="pjuwb"><del id="pjuwb"><button id="pjuwb"><pre id="pjuwb"></pre></button></del></ul><abbr id="pjuwb"></abbr><strong id="pjuwb"><code id="pjuwb"><strong id="pjuwb"></strong></code></strong><option id="pjuwb"></option><optgroup id="pjuwb"><bdo id="pjuwb"><code id="pjuwb"></code></bdo></optgroup><mark id="pjuwb"><em id="pjuwb"><font id="pjuwb"></font></em></mark><acronym id="pjuwb"><code id="pjuwb"></code></acronym><dl id="pjuwb"></dl><em id="pjuwb"></em><object id="pjuwb"><input id="pjuwb"><object id="pjuwb"></object></input></object><output id="pjuwb"><dd id="pjuwb"></dd></output><option id="pjuwb"><button id="pjuwb"><option id="pjuwb"></option></button></option><small id="pjuwb"></small></div> <a href="http://gdjuba.com" target="_blank">久久久精品国产免大香伊</a>| <a href="http://www-401313.com" target="_blank">亚洲成人资源</a>| <a href="http://xingmaokeji.com" target="_blank">一本不卡影院</a>| <a href="http://136066.com" target="_blank">免费观看成人</a>| <a href="http://sikixixw12.com" target="_blank">亚洲欧美久久久</a>| <a href="http://easypufu.com" target="_blank">欧美日韩在线高清</a>| <a href="http://wwwp6660.com" target="_blank">亚洲精品色婷婷福利天堂</a>| <a href="http://fobdoer.com" target="_blank">久久久综合网</a>| <a href="http://22127c.com" target="_blank">亚洲欧美国产高清</a>| <a href="http://jlkcjz.com" target="_blank">国产精品swag</a>| <a href="http://popowq.com" target="_blank">亚洲色诱最新</a>| <a href="http://uniconmgt.com" target="_blank">亚洲精品久久久久久久久久久久</a>| <a href="http://cczm4.com" target="_blank">狂野欧美一区</a>| <a href="http://ycgg008.com" target="_blank">在线精品一区</a>| <a href="http://jizzizz.com" target="_blank">麻豆成人在线观看</a>| <a href="http://6hzl8.com" target="_blank">久久激情五月婷婷</a>| <a href="http://wwzz3.com" target="_blank">国产亚洲人成a一在线v站</a>| <a href="http://gx2020.com" target="_blank">先锋影音国产一区</a>| <a href="http://aqxiangtai.com" target="_blank">亚洲午夜激情网站</a>| <a href="http://diao66.com" target="_blank">国产精品爱啪在线线免费观看</a>| <a href="http://www-964664.com" target="_blank">99国产一区</a>| <a href="http://dsjgqc.com" target="_blank">亚洲人成欧美中文字幕</a>| <a href="http://www18998.com" target="_blank">欧美好骚综合网</a>| <a href="http://118936.com" target="_blank">亚洲精品欧洲</a>| <a href="http://kinghongs.com" target="_blank">91久久综合</a>| <a href="http://www-888690.com" target="_blank">欧美韩国在线</a>| <a href="http://leohacks.com" target="_blank">aa日韩免费精品视频一</a>| <a href="http://csjtzn.com" target="_blank">亚洲精选在线</a>| <a href="http://7776701.com" target="_blank">欧美日韩国产精品一区</a>| <a href="http://400206.com" target="_blank">一本久久综合亚洲鲁鲁</a>| <a href="http://ca88tv.com" target="_blank">亚洲精品国产拍免费91在线</a>| <a href="http://wslsp.com" target="_blank">欧美精品一区二区三</a>| <a href="http://www01614.com" target="_blank">亚洲美女中文字幕</a>| <a href="http://xunlei520.com" target="_blank">亚洲精品免费在线播放</a>| <a href="http://ganmabook.com" target="_blank">欧美激情精品</a>| <a href="http://bjopl.com" target="_blank">夜夜夜久久久</a>| <a href="http://911mmm.com" target="_blank">中日韩高清电影网</a>| <a href="http://www8qa.com" target="_blank">国产精品久久久久久影院8一贰佰</a>| <a href="http://mm910.com" target="_blank">亚洲一区二区动漫</a>| <a href="http://lmjqav.com" target="_blank">亚洲调教视频在线观看</a>| <a href="http://9kkkb.com" target="_blank">国产欧美婷婷中文</a>| <a href="http://whdzjc.com" target="_blank">久久精品一二三</a>| <a href="http://babylonmovi.com" target="_blank">久久福利精品</a>| <a href="http://828121.com" target="_blank">亚洲国产裸拍裸体视频在线观看乱了中文 </a>| <a href="http://173168.com" target="_blank">麻豆av一区二区三区</a>| <a href="http://5588207.com" target="_blank">伊人狠狠色j香婷婷综合</a>| <a href="http://216667.com" target="_blank">免费不卡中文字幕视频</a>| <a href="http://114mz.com" target="_blank">美女国内精品自产拍在线播放</a>| <a href="http://56701sy.com" target="_blank">亚洲国产专区校园欧美</a>| <a href="http://www47777.com" target="_blank">91久久久久久国产精品</a>| <a href="http://605012.com" target="_blank">欧美日韩精品免费观看</a>| <a href="http://48488a.com" target="_blank">午夜精品美女自拍福到在线 </a>| <a href="http://xiehaihua.com" target="_blank">欧美日韩福利视频</a>| <a href="http://667939.com" target="_blank">亚洲一二三区在线观看</a>| <a href="http://yw133777.com" target="_blank">亚洲手机在线</a>| <a href="http://72avav.com" target="_blank">国产一区二区无遮挡</a>| <a href="http://g2000vip.com" target="_blank">乱中年女人伦av一区二区</a>| <a href="http://www47067.com" target="_blank">久久中文在线</a>| <a href="http://2589999.com" target="_blank">a91a精品视频在线观看</a>| <a href="http://jj8518.com" target="_blank">亚洲午夜精品17c</a>| <a href="http://cgnwp.com" target="_blank">韩国av一区</a>| <a href="http://zw1019.com" target="_blank">亚洲国产精品一区二区第一页</a>| <a href="http://9885888.com" target="_blank">欧美日韩一区二区三区四区在线观看</a>| <a href="http://2061856.com" target="_blank">亚洲免费视频网站</a>| <a href="http://www-44899.com" target="_blank">欧美在线日韩</a>| <a href="http://152mu.com" target="_blank">亚洲福利在线看</a>| <a href="http://322033.com" target="_blank">亚洲另类自拍</a>| <a href="http://www-216678.com" target="_blank">国产三级精品三级</a>| <a href="http://chaoxibg.com" target="_blank">欧美华人在线视频</a>| <a href="http://szjyf668.com" target="_blank">国产精品扒开腿做爽爽爽软件</a>| <a href="http://qiezi2vip.com" target="_blank">久久福利一区</a>| <a href="http://sinojinxing.com" target="_blank">免费亚洲电影</a>| <a href="http://ccltb.com" target="_blank">亚洲欧美日本另类</a>| <a href="http://www11108b.com" target="_blank">久久精品成人一区二区三区</a>| <a href="http://aqdit2022.com" target="_blank">亚洲裸体视频</a>| <a href="http://whaylan.com" target="_blank">亚洲尤物在线视频观看</a>| <a href="http://www-49386.com" target="_blank">亚洲电影免费观看高清完整版在线观看 </a>| <a href="http://cmtqd.com" target="_blank">六月丁香综合</a>| <a href="http://pao449.com" target="_blank">欧美日本高清</a>| <a href="http://www19898.com" target="_blank">久久久国产午夜精品</a>| <a href="http://ahhyez.com" target="_blank">欧美高清影院</a>| <a href="http://nc04.com" target="_blank">久久国产毛片</a>| <a href="http://www5566szy.com" target="_blank">欧美精品久久久久久久久久</a>| <a href="http://66666556.com" target="_blank">久久99在线观看</a>| <a href="http://syddzs.com" target="_blank">女同一区二区</a>| <a href="http://xw4433.com" target="_blank">欧美中文字幕在线观看</a>| <a href="http://yjdm296.com" target="_blank">欧美aⅴ99久久黑人专区</a>| <a href="http://www4455va.com" target="_blank">亚洲欧美自拍偷拍</a>| <a href="http://szxrdr.com" target="_blank">美女视频一区免费观看</a>| <a href="http://ww4477.com" target="_blank">亚洲欧美日韩区</a>| <a href="http://yzsss.com" target="_blank">蜜桃久久av一区</a>| <a href="http://o10669.com" target="_blank">欧美亚洲免费在线</a>| <a href="http://www962aa.com" target="_blank">欧美激情精品久久久久久黑人</a>| <a href="http://www1126v.com" target="_blank">午夜日韩在线观看</a>| <a href="http://5s5s5s.com" target="_blank">欧美成人性生活</a>| <a href="http://430390.com" target="_blank">久久国产精品一区二区三区</a>| <a href="http://4448884.com" target="_blank">欧美国产精品劲爆</a>| <a href="http://969093.com" target="_blank">久久久91精品</a>| <a href="http://tp-88.com" target="_blank">欧美午夜宅男影院在线观看</a>| <a href="http://4884888.com" target="_blank">欧美成人免费在线</a>| <a href="http://cczm4.com" target="_blank">国产精品一区二区视频</a>| <a href="http://lgaoxiao.com" target="_blank">亚洲欧洲久久</a>| <a href="http://spvicarb.com" target="_blank">精品96久久久久久中文字幕无</a>| <a href="http://jgj230230.com" target="_blank">一本久久精品一区二区</a>| <a href="http://mmmm26.com" target="_blank">亚洲国产日韩欧美在线99</a>| <a href="http://794579.com" target="_blank">亚洲欧美日韩中文视频</a>| <a href="http://xiaobi13.com" target="_blank">一本色道久久88综合亚洲精品ⅰ</a>| <a href="http://epiegame.com" target="_blank">久久精品一级爱片</a>| <a href="http://boocnn.com" target="_blank">先锋影音久久</a>| <a href="http://038226.com" target="_blank">欧美日韩成人精品</a>| <a href="http://770456.com" target="_blank">欧美黄在线观看</a>| <a href="http://8331651.com" target="_blank">国产视频观看一区</a>| <a href="http://zd-jm.com" target="_blank">日韩写真在线</a>| <a href="http://995688.com" target="_blank">最近中文字幕日韩精品 </a>| <a href="http://nc04.com" target="_blank">国产精品男人爽免费视频1 </a>| <a href="http://977764.com" target="_blank">久久人人97超碰国产公开结果</a>| <a href="http://myasker.com" target="_blank">欧美日韩免费观看一区三区</a>| <a href="http://www-55125.com" target="_blank">欧美成年人视频</a>| <a href="http://smiczbb.com" target="_blank">国模私拍一区二区三区</a>| <a href="http://jizzdo.com" target="_blank">亚洲一区二区三区中文字幕在线</a>| <a href="http://yw3328.com" target="_blank">日韩午夜在线视频</a>| <a href="http://2502255.com" target="_blank">老牛国产精品一区的观看方式</a>| <a href="http://caoxiu33.com" target="_blank">久久久久国色av免费观看性色</a>| <a href="http://qq666qq.com" target="_blank">国产精品九九</a>| <a href="http://nvpuow.com" target="_blank">一本色道久久88综合亚洲精品ⅰ</a>| <a href="http://ww9494.com" target="_blank">亚洲精品国产精品国自产在线</a>| <a href="http://448968.com" target="_blank">久久国产精品亚洲77777</a>| <a href="http://5gn4y.com" target="_blank">性18欧美另类</a>| <a href="http://sdsptl.com" target="_blank">国产精品xnxxcom</a>| <a href="http://993934.com" target="_blank">av成人福利</a>| <a href="http://5773000.com" target="_blank">99国产一区</a>| <a href="http://77777gao.com" target="_blank">欧美激情亚洲一区</a>| <a href="http://aijiaoji.com" target="_blank">欧美激情第二页</a>| <a href="http://nztd20.com" target="_blank">在线观看日韩av</a>| <a href="http://84172199.com" target="_blank">久久久精品日韩欧美</a>| <a href="http://yw8333.com" target="_blank">久久久福利视频</a>| <a href="http://hhh699.com" target="_blank">国产日韩三区</a>| <a href="http://987gqb.com" target="_blank">亚洲欧美一区二区三区极速播放</a>| <a href="http://vod3366.com" target="_blank">亚洲女人天堂成人av在线</a>| <a href="http://www-90422.com" target="_blank">欧美日韩国产麻豆</a>| <a href="http://yeepey.com" target="_blank">亚洲欧洲在线一区</a>| <a href="http://by33336.com" target="_blank">亚洲靠逼com</a>| <a href="http://ttmitch.com" target="_blank">欧美激情网站在线观看</a>| <a href="http://8xyxs1.com" target="_blank">亚洲第一天堂av</a>| <a href="http://gaysexcube.com" target="_blank">亚洲国产老妈</a>| <a href="http://xissy.com" target="_blank">美日韩在线观看</a>| <a href="http://223zzz.com" target="_blank">欧美福利在线</a>| <a href="http://www33779.com" target="_blank">亚洲精品视频在线观看免费</a>| <a href="http://www16axax.com" target="_blank">免费一级欧美在线大片</a>| <a href="http://246767.com" target="_blank">欧美大尺度在线观看</a>| <a href="http://yw5531.com" target="_blank">亚洲黄一区二区</a>| <a href="http://by56677.com" target="_blank">欧美国产在线视频</a>| <a href="http://ydpszcn.com" target="_blank">亚洲久久成人</a>| <a href="http://tzhsdy.com" target="_blank">亚洲视频二区</a>| <a href="http://794579.com" target="_blank">国产精品福利在线</a>| <a href="http://888nei.com" target="_blank">亚洲图片在线观看</a>| <a href="http://ywy99.com" target="_blank">欧美一区二区三区日韩</a>| <a href="http://o74sokyoss.com" target="_blank">国产精品亚洲精品</a>| <a href="http://bandycup.com" target="_blank">香蕉av777xxx色综合一区</a>| <a href="http://012928.com" target="_blank">久久久久一区二区三区</a>| <a href="http://ooonefteprompellets.com" target="_blank">国产性天天综合网</a>| <a href="http://989p.com" target="_blank">久久久久久久久岛国免费</a>| <a href="http://lfxhfh.com" target="_blank">免费观看在线综合色</a>| <a href="http://954k.com" target="_blank">亚洲人成在线观看</a>| <a href="http://sqms2013.com" target="_blank">欧美女同视频</a>| <a href="http://www33444.com" target="_blank">亚洲视频日本</a>| <a href="http://www-kj777.com" target="_blank">久久成人免费网</a>| <a href="http://2456yo.com" target="_blank">在线观看成人av电影</a>| <a href="http://25axxa.com" target="_blank">欧美不卡视频</a>| <a href="http://eee104.com" target="_blank">99精品久久免费看蜜臀剧情介绍</a>| <a href="http://budanbao.com" target="_blank">亚洲资源在线观看</a>| <a href="http://chinagreetown.com" target="_blank">国产伦一区二区三区色一情</a>| <a href="http://filmcameralibrary.com" target="_blank">欧美一区二区三区视频在线 </a>| <a href="http://www-293456.com" target="_blank">久久躁日日躁aaaaxxxx</a>| <a href="http://eastasp.com" target="_blank">亚洲福利在线看</a>| <a href="http://3644688.com" target="_blank">欧美日产一区二区三区在线观看</a>| <a href="http://av2027.com" target="_blank">中文av一区二区</a>| <a href="http://pabjzz.com" target="_blank">久久精品国产清高在天天线</a>| <a href="http://chinasck.com" target="_blank">精品999成人</a>| <a href="http://jiajianpei.com" target="_blank">欧美大片在线影院</a>| <a href="http://036762.com" target="_blank">99国产精品久久久久久久</a>| <a href="http://www-37277.com" target="_blank">香蕉久久久久久久av网站</a>| <a href="http://kk8c.com" target="_blank">国内成人精品视频</a>| <a href="http://7770790.com" target="_blank">欧美国产精品久久</a>| <a href="http://3188m.com" target="_blank">在线视频免费在线观看一区二区</a>| <a href="http://ategpu.com" target="_blank">欧美在线观看一区二区</a>| <a href="http://hfztkyhfz.com" target="_blank">雨宫琴音一区二区在线</a>| <a href="http://dlwansheng.com" target="_blank">欧美精品一区三区</a>| <a href="http://azaz7.com" target="_blank">午夜性色一区二区三区免费视频</a>| <a href="http://jiyixitong.com" target="_blank">麻豆成人在线观看</a>| <a href="http://1181318.com" target="_blank">一本色道久久精品</a>| <a href="http://essuee.com" target="_blank">国产亚洲欧美日韩一区二区</a>| <a href="http://845821.com" target="_blank">欧美+亚洲+精品+三区</a>| <a href="http://playav111.com" target="_blank">妖精成人www高清在线观看</a>| <a href="http://498626.com" target="_blank">久久精品一区二区三区不卡牛牛</a>| <a href="http://www-8617.com" target="_blank">亚洲破处大片</a>| <a href="http://xian369.com" target="_blank">国产精品色网</a>| <a href="http://www-132377.com" target="_blank">美女诱惑黄网站一区</a>| <a href="http://hhhh19.com" target="_blank">一区二区三区四区五区精品视频</a>| <a href="http://wwwby6682.com" target="_blank">久久久久久久激情视频</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>