锘??xml version="1.0" encoding="utf-8" standalone="yes"?>996久久国产精品线观看,久久久久久国产精品美女,久久国产精品偷99http://www.shnenglu.com/heidaizx/category/5379.htmlzh-cnMon, 19 May 2008 20:22:29 GMTMon, 19 May 2008 20:22:29 GMT60闂暎鍒楁硶緇勭粐鐨勬暎鍒楄〃http://www.shnenglu.com/heidaizx/articles/37639.htmlheidaizxheidaizxSun, 02 Dec 2007 06:58:00 GMThttp://www.shnenglu.com/heidaizx/articles/37639.htmlhttp://www.shnenglu.com/heidaizx/comments/37639.htmlhttp://www.shnenglu.com/heidaizx/articles/37639.html#Feedback0http://www.shnenglu.com/heidaizx/comments/commentRss/37639.htmlhttp://www.shnenglu.com/heidaizx/services/trackbacks/37639.html
#include<iostream>
#include
<stdlib.h>
using namespace std;
const int DefaultSize=100;
enum KindOfStatus{Active,
Empty,Deleted};  //鍏冪礌鍒嗙被(媧誨姩/絀?/span>/鍒?
template
<class E,class K>
class HashTable
{
public:

    HashTable(
const int d,int sz=DefaultSize);
    ~HashTable(){delete []ht;delete []info;}
    bool Insert(
const E &e1);  //鍦ㄦ暎鍒楄〃涓彃鍏1
    bool Remove(
const K k1); //鍦ㄦ暎鍒楄〃涓垹闄?br>    E Search(const K k1,E& e1)const;//鍦ㄦ暎鍒楄〃鎼滅儲k1
    void makeEmpty();       
//緗暎鍒楄〃涓虹┖
private:
    
int divitor;          //鏁e垪琛ㄧ殑闄ゆ暟
    
int CurrentSize,TableSize;  //褰撳墠妗舵暟鍙婃渶澶ф《鏁?br>    E *ht;                     //鏁e垪琛ㄥ瓨鍌ㄦ暟緇?br>    KindOfStatus *info;        //鐘舵佹暟緇?br>    int FindPos(const K k1)const//鏁e垪鍑芥暟,璁$畻鍒濆妗跺彿

};

---------------hashing.cpp----------------------------
#include"hashing.h"
template
<class E,class K>
HashTable
<E,K>::HashTable(const int d,int sz)
{
    divitor
=d;
    TableSize
=sz;
    CurrentSize
=0;
    ht
=new E[TableSize];
    info
=new KindOfStatus[TableSize];
    
for(int i=0;i<TableSize;i++)
        info[i]
=Empty;
};

template
<class E,class K>
int HashTable<E,K>::FindPos(const K k1)const
{
    
int i=k1%divitor;//璁$畻鍒濆妗跺彿
    
int j=i;       //媯嫻嬩笅涓絀烘《涓嬫爣
    
do
    {    
        
if(info[j]==Empty||info[j]==Active&&ht[j]==k1)    return j;   //鎵懼埌
        j
=(j+1)%TableSize;            //褰撳仛寰幆琛ㄥ鐞嗭紝鎵句笅涓涓┖妗?br>    }while(j!=i);
    return j;
};

template
<class E,class K>
bool HashTable
<E,K>::Insert(const E& e1)
{
    K k1
=e1;       //閲嶈澆鍑芥暟::鎶藉彇鍑芥暟
    
int i=FindPos(k1); //鐢ㄦ暎鍒楀嚱鏁拌綆楁《鍙?br>    if(info[i]!=Active)
    {
        ht[i]
=e1;
        info[i]
=Active;
        CurrentSize
++;
        return 
true;
    }
    
if(info[i]==Active&&ht[i]==e1)
    {
        cout
<<"琛ㄤ腑宸叉湁鍏冪礌,涓嶈兘鎻掑叆!"<<endl;
        return 
false;
    }
    cout
<<"琛ㄥ凡婊?涓嶈兘鎻掑叆鏁版嵁!";
    return 
false;
};

template
<class E,class K>
bool HashTable
<E,K>::Remove(const K k1)
{
    
int i=FindPos(k1);
    
if(info[i]==Active)
    {
        info[i]
=Deleted;
        CurrentSize
--;
        return 
true;
    }
    
else return false;
};

template
<class E,class K>
E HashTable
<E,K>::Search(const K k1,E& e1)const
{
    
int i=FindPos(k1);
    
if(info[i]!=Active||ht[i]!=k1) return false;
    e1
=ht[i];
    return e1;
};

template
<class E,class K>
void HashTable
<E,K>::makeEmpty()
{
    
for(int i=0;i<TableSize;i++)
        info[i]
=Empty;
    CurrentSize
=0;
};
---------------main.cpp--------------------------

#include"hashing.cpp"
int menu()
{
    int choice;

    cout<<"               *************鏁e垪鍑芥暟鐨勫熀鏈搷浣?***********"<<endl<<endl;
    cout<<"                         鍦ㄦ暎鍒楄〃鎻掑叆鍏冪礌錛岃鎸?"<<endl;
    cout<<"                         閫昏緫鍒犻櫎鏁e垪琛ㄥ厓绱狅紝璇鋒寜2"<<endl;
    cout<<"                         鍦ㄦ暎鍒楄〃涓悳绱㈠叧閿爜鐨勫鹼紝璇鋒寜3"<<endl;
    cout<<"                         閫鍑猴紝璇鋒寜4"<<endl<<endl;
    cout<<"               *****************************************"<<endl<<endl;

    cout<<"                          璇烽夋嫨:";
    cin>>choice;
    return choice;
}

int main()
{
    HashTable<int,int> hash(2,10);
    bool exit=false;
    while(true)
    {
        int choice=menu();
        switch(choice)
        {
        case 1:
            int s;
            cout<<"                   璇瘋緭鍏ヨ鎻掑叆鍊煎叧閿爜:";
            cin>>s;
            cout<<"                   "<<hash.Insert(s)<<endl;break;
        case 2:
            int c;
            cout<<"                   璇瘋緭鍏ヨ杈撳嚭鍊煎叧閿爜:";
            cin>>c;
            cout<<"                   "<<hash.Remove(c)<<endl;break;
        case 3:
            int y;
            cout<<"                   璇瘋緭鍏ヨ鏌ヨ鍊肩殑鍏抽敭鐮?";
            cin>>y;
            int z;
            cout<<"                   "<<hash.Search(y,z)<<endl;break;
        case 4:
            exit=true;break;
            
        }
        system("pause");
        system("cls");
       
        if(exit==true)
            break;
    }
    return 0;
}





heidaizx 2007-12-02 14:58 鍙戣〃璇勮
]]>
浜屽弶鏍戠殑綆鍗曟搷浣?/title><link>http://www.shnenglu.com/heidaizx/articles/37638.html</link><dc:creator>heidaizx</dc:creator><author>heidaizx</author><pubDate>Sun, 02 Dec 2007 06:54:00 GMT</pubDate><guid>http://www.shnenglu.com/heidaizx/articles/37638.html</guid><wfw:comment>http://www.shnenglu.com/heidaizx/comments/37638.html</wfw:comment><comments>http://www.shnenglu.com/heidaizx/articles/37638.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heidaizx/comments/commentRss/37638.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heidaizx/services/trackbacks/37638.html</trackback:ping><description><![CDATA[ --------------------BinaryTree.h------------------------------- <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include</span><span style="color: #000000;"><</span><span style="color: #000000;">iostream</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include</span><span style="color: #000000;"><</span><span style="color: #000000;">stdlib.h</span><span style="color: #000000;">></span><span style="color: #000000;"><br>using namespace std;<br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>struct BinTreeNode<br>{<br>    T data;<br>    BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">leftChild,</span><span style="color: #000000;">*</span><span style="color: #000000;">rightChild;  </span><span style="color: #000000;">//</span><span style="color: #000000;">宸﹀彸瀛╁瓙鎸囬拡<br>    BinTreeNode():leftChild(</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">),rightChild(</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">){}<br>    BinTreeNode(T x,BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">l</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">,BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">r</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">):data(x),leftChild(l),rightChild(r){}<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>class BinaryTree<br>{<br></span><span style="color: #0000ff;">public</span><span style="color: #000000;">:<br>    <br></span><span style="color: #000000;">//</span><span style="color: #000000;">    BinaryTree():root(</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">){}<br>    BinaryTree():root(</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">){CreateBinTree(root);}<br>    void PreOrder(){PreOrder(root);}    </span><span style="color: #000000;">//</span><span style="color: #000000;">鍓嶅簭閬嶅巻<br>    void inOrder(){inOrder(root);}    </span><span style="color: #000000;">//</span><span style="color: #000000;">涓簭閬嶅巻<br>    void postOrder(){postOrder(root);}    </span><span style="color: #000000;">//</span><span style="color: #000000;">鍚庡簭閬嶅巻<br>    <br>    <br>protected:<br>    BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">root;                 </span><span style="color: #000000;">//</span><span style="color: #000000;">浜屽弶鏍戠殑鏍圭粨鐐規寚閽?br></span><span style="color: #000000;">//</span><span style="color: #000000;">    void Print(BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">p);       </span><span style="color: #000000;">//</span><span style="color: #000000;">杈撳嚭浜屽弶鏍戞瘡涓粨鐐圭殑鍊?br>    void CreateBinTree(BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*&</span><span style="color: #000000;">subTree);</span><span style="color: #000000;">//</span><span style="color: #000000;">鍒╃敤浜屽弶鏍戝墠搴忛亶鍘嗙敓鎴愪簩鍙夋爲<br>    void PreOrder(BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*&</span><span style="color: #000000;">subTree);<br>    void inOrder(BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*&</span><span style="color: #000000;">subTree);    <br>    void postOrder(BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*&</span><span style="color: #000000;">subTree);    <br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;">                 <br>void BinaryTree</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::CreateBinTree(BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*&</span><span style="color: #000000;">subTree)<br>{<br>    char value;<br>    cin</span><span style="color: #000000;">>></span><span style="color: #000000;">value;<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(value</span><span style="color: #000000;">==</span><span style="color: #008000;">'</span><span style="color: #008000;">#') subTree=NULL;</span><span style="color: #008000;"><br></span><span style="color: #000000;">    </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>    {<br>        subTree</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">(value);<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(subTree</span><span style="color: #000000;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">)<br>        {<br>            cerr</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;">;<br>            </span><span style="color: #0000ff;">exit</span><span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">);<br>        }<br>    <br>        CreateBinTree(subTree</span><span style="color: #000000;">-></span><span style="color: #000000;">leftChild);<br>        CreateBinTree(subTree</span><span style="color: #000000;">-></span><span style="color: #000000;">rightChild);<br>    }<br><br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;">   <br>void BinaryTree</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::PreOrder(BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*&</span><span style="color: #000000;">subTree)<br>{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(subTree!</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">)<br>    {<br>        cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">subTree</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: #000000;"> </span><span style="color: #000000;">"</span><span style="color: #000000;">;<br>        PreOrder(subTree</span><span style="color: #000000;">-></span><span style="color: #000000;">leftChild);<br>        PreOrder(subTree</span><span style="color: #000000;">-></span><span style="color: #000000;">rightChild);<br>    }<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;">   <br>void BinaryTree</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::inOrder(BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*&</span><span style="color: #000000;">subTree)<br>{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(subTree!</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">)<br>    {<br>        <br>        inOrder(subTree</span><span style="color: #000000;">-></span><span style="color: #000000;">leftChild);<br>        cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">subTree</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: #000000;"> </span><span style="color: #000000;">"</span><span style="color: #000000;">;<br>        inOrder(subTree</span><span style="color: #000000;">-></span><span style="color: #000000;">rightChild);<br>    }<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;">   <br>void BinaryTree</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::postOrder(BinTreeNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*&</span><span style="color: #000000;">subTree)<br>{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(subTree!</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">)<br>    {<br>    <br>        postOrder(subTree</span><span style="color: #000000;">-></span><span style="color: #000000;">leftChild);<br>        postOrder(subTree</span><span style="color: #000000;">-></span><span style="color: #000000;">rightChild);<br>        cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">subTree</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: #000000;"> </span><span style="color: #000000;">"</span><span style="color: #000000;">;<br>    }<br>};<br><br><br><br></span></div> --------------------------main.cpp----------------------------------<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include</span><span style="color: #000000;">"</span><span style="color: #000000;">BinaryTree.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br></span><span style="color: #000000;"></span><span style="color: #000000;"><br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> menu()<br>{<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> choice</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>    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</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br><br>    cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">"</span><span style="color: #000000;">                          鍓嶅簭閬嶅巻杈撳嚭浜屽弶鏍戯紝璇鋒寜1:</span><span style="color: #000000;">"</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>    cout</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;"><<</span><span style="color: #000000;">endl;<br>    cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">"</span><span style="color: #000000;">                          鍚庡簭閬嶅巻杈撳嚭浜屽弶鏍戯紝璇鋒寜3:</span><span style="color: #000000;">"</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>    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</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>    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</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>    cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">"</span><span style="color: #000000;">               Please enter the number:</span><span style="color: #000000;">"</span><span style="color: #000000;">;<br>    cin</span><span style="color: #000000;">>></span><span style="color: #000000;">choice;<br>    return choice;<br>}<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main()<br>{<br>    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>    BinaryTree</span><span style="color: #000000;"><</span><span style="color: #000000;">char</span><span style="color: #000000;">></span><span style="color: #000000;"> tree;<br><br>    bool </span><span style="color: #0000ff;">exit</span><span style="color: #000000;">=</span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>    <br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(</span><span style="color: #0000ff;">true</span><span style="color: #000000;">)<br>    {<br>        </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> choice</span><span style="color: #000000;">=</span><span style="color: #000000;">menu();<br>        <br>        switch(choice)<br>        {<br>            </span><span style="color: #0000ff;">case</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">:<br>                tree.PreOrder();break;<br>            </span><span style="color: #0000ff;">case</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;">:<br>                tree.inOrder();break;<br>            </span><span style="color: #0000ff;">case</span><span style="color: #000000;"> </span><span style="color: #000000;">3</span><span style="color: #000000;">:<br>                tree.postOrder();;break;<br><br>            </span><span style="color: #0000ff;">case</span><span style="color: #000000;"> </span><span style="color: #000000;">4</span><span style="color: #000000;">:</span><span style="color: #0000ff;">exit</span><span style="color: #000000;">=</span><span style="color: #0000ff;">true</span><span style="color: #000000;">;break;<br>            default: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;">;break;<br>            <br>        }<br>        system(</span><span style="color: #000000;">"</span><span style="color: #000000;">pause</span><span style="color: #000000;">"</span><span style="color: #000000;">);             </span><span style="color: #000000;">//</span><span style="color: #000000;">鏆傚仠<br>        system(</span><span style="color: #000000;">"</span><span style="color: #000000;">cls</span><span style="color: #000000;">"</span><span style="color: #000000;">);               </span><span style="color: #000000;">//</span><span style="color: #000000;">娓呭睆<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #0000ff;">exit</span><span style="color: #000000;">==</span><span style="color: #0000ff;">true</span><span style="color: #000000;">) break;<br>    }<br>    return </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}</span></div> <br><br> <img src ="http://www.shnenglu.com/heidaizx/aggbug/37638.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heidaizx/" target="_blank">heidaizx</a> 2007-12-02 14:54 <a href="http://www.shnenglu.com/heidaizx/articles/37638.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Josephus鐨勯摼琛ㄥ疄鐜?/title><link>http://www.shnenglu.com/heidaizx/articles/36868.html</link><dc:creator>heidaizx</dc:creator><author>heidaizx</author><pubDate>Sun, 18 Nov 2007 06:42:00 GMT</pubDate><guid>http://www.shnenglu.com/heidaizx/articles/36868.html</guid><wfw:comment>http://www.shnenglu.com/heidaizx/comments/36868.html</wfw:comment><comments>http://www.shnenglu.com/heidaizx/articles/36868.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heidaizx/comments/commentRss/36868.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heidaizx/services/trackbacks/36868.html</trackback:ping><description><![CDATA[-----------------------------Josephus.h---------------------------------------------<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include</span><span style="color: #000000;"><</span><span style="color: #000000;">iostream</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include</span><span style="color: #000000;"><</span><span style="color: #000000;">stdlib.h</span><span style="color: #000000;">></span><span style="color: #000000;"><br>using namespace std;<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>struct CircLinkNode<br>{<br>    T data;<br>    CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">link;<br>    CircLinkNode(CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #0000ff;">next</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">):link(</span><span style="color: #0000ff;">next</span><span style="color: #000000;">){}<br>    CircLinkNode(T d,CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">>*</span><span style="color: #0000ff;">next</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">):data(d),link(</span><span style="color: #0000ff;">next</span><span style="color: #000000;">){}<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>class CircList<br>{<br></span><span style="color: #0000ff;">public</span><span style="color: #000000;">:<br><br>    CircList(){first</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">),first</span><span style="color: #000000;">-></span><span style="color: #000000;">link</span><span style="color: #000000;">=</span><span style="color: #000000;">first;}</span><span style="color: #000000;">//</span><span style="color: #000000;">瀹氫箟涓哄驚鐜摼琛?br>    ~CircList(){}<br>    CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">getHead()</span><span style="color: #0000ff;">const</span><span style="color: #000000;">{return first;}<br>    CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">Locate(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> </span><span style="color: #000000;">&</span><span style="color: #000000;">i);<br>    bool Insert(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> </span><span style="color: #000000;">&</span><span style="color: #000000;">i);<br></span><span style="color: #0000ff;">private</span><span style="color: #000000;">:<br>    CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">first;<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">CircList</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::Locate(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> </span><span style="color: #000000;">&</span><span style="color: #000000;">i)<br>{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(i</span><span style="color: #000000;"><</span><span style="color: #000000;">0</span><span style="color: #000000;">) return </span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">;<br>    CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">current</span><span style="color: #000000;">=</span><span style="color: #000000;">first;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> k</span><span style="color: #000000;">=</span><span style="color: #000000;">2</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(current!</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">&&</span><span style="color: #000000;">k</span><span style="color: #000000;"><</span><span style="color: #000000;">i)<br>    {<br>        current</span><span style="color: #000000;">=</span><span style="color: #000000;">current</span><span style="color: #000000;">-></span><span style="color: #000000;">link;<br>        k</span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>    }<br>    return current;<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>bool CircList</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::Insert(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> </span><span style="color: #000000;">&</span><span style="color: #000000;">i)<br>{<br>    CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">current</span><span style="color: #000000;">=</span><span style="color: #000000;">Locate(i);<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(current</span><span style="color: #000000;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">) return </span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>    CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">newNode</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">(i);<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(newNode</span><span style="color: #000000;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">)<br>    {<br>        cerr</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>        </span><span style="color: #0000ff;">exit</span><span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">);<br>    }<br>    newNode</span><span style="color: #000000;">-></span><span style="color: #000000;">link</span><span style="color: #000000;">=</span><span style="color: #000000;">first;<br>    current</span><span style="color: #000000;">-></span><span style="color: #000000;">link</span><span style="color: #000000;">=</span><span style="color: #000000;">newNode;<br><br>    return </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>};</span></div> -------------------------------main.cpp-----------------------------------<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include</span><span style="color: #000000;">"</span><span style="color: #000000;">CircList.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>void Josephus(CircList</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">>&</span><span style="color: #000000;">Js ,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> n,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> m)<br>{<br>    CircLinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">p</span><span style="color: #000000;">=</span><span style="color: #000000;">Js.getHead(),</span><span style="color: #000000;">*</span><span style="color: #000000;">pre</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i,j;<br>    </span><span style="color: #0000ff;">for</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;">n</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>    {<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(j</span><span style="color: #000000;">=</span><span style="color: #000000;">1</span><span style="color: #000000;">;j</span><span style="color: #000000;"><</span><span style="color: #000000;">m;j</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        {<br>            pre</span><span style="color: #000000;">=</span><span style="color: #000000;">p;<br>            p</span><span style="color: #000000;">=</span><span style="color: #000000;">p</span><span style="color: #000000;">-></span><span style="color: #000000;">link;<br>        }<br>        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;">p</span><span style="color: #000000;">-></span><span style="color: #000000;">data</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>        pre</span><span style="color: #000000;">-></span><span style="color: #000000;">link</span><span style="color: #000000;">=</span><span style="color: #000000;">p</span><span style="color: #000000;">-></span><span style="color: #000000;">link;<br>        delete p;<br>        p</span><span style="color: #000000;">=</span><span style="color: #000000;">pre</span><span style="color: #000000;">-></span><span style="color: #000000;">link;<br>    }<br>};<br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main()<br>{<br>    CircList</span><span style="color: #000000;"><</span><span style="color: #0000ff;">int</span><span style="color: #000000;">></span><span style="color: #000000;"> clist;<br><br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i,n,m;<br>    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;">;<br>    cin</span><span style="color: #000000;">>></span><span style="color: #000000;">n</span><span style="color: #000000;">>></span><span style="color: #000000;">m;<br>    </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i</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;">n;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        clist.Insert(i);<br>    Josephus(clist,n,m);<br>    return </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}</span></div> 鍒氬鏁版嵁緇撴瀯灝卞簲璇ュ疄鐜扮殑紼嬪簭錛屽懙鍛碉紝鍒扮幇鍦ㄦ墠鍘誨仛.<br><br>涓嬮潰鏄互鍓嶆病瀛︽暟鎹粨鏋勪箣鍓嶆墍鍐欑殑浠g爜<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include</span><span style="color: #000000;"><</span><span style="color: #000000;">iostream</span><span style="color: #000000;">></span><span style="color: #000000;"><br>using namespace std;<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main()<br>{<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> count</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> s</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;</span><span style="color: #000000;">//</span><span style="color: #000000;">璁板綍閫鍑虹殑浜虹殑涓暟<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> N;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> key;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> a[</span><span style="color: #000000;">100</span><span style="color: #000000;">];<br>    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;">;<br>    cin</span><span style="color: #000000;">>></span><span style="color: #000000;">N</span><span style="color: #000000;">>></span><span style="color: #000000;">key;<br>    </span><span style="color: #0000ff;">for</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;">N;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        a[i]</span><span style="color: #000000;">=</span><span style="color: #000000;">i</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">for</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;">N;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>    {<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(a[i]</span><span style="color: #000000;">==-</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>        {<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(i</span><span style="color: #000000;">==</span><span style="color: #000000;">N</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">//</span><span style="color: #000000;">闃叉continue浣垮驚鐜鍑?br>                i</span><span style="color: #000000;">=-</span><span style="color: #000000;">1</span><span style="color: #000000;">;<br>            continue;<br>        }<br>        count</span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>    <br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(count</span><span style="color: #000000;">==</span><span style="color: #000000;">key)<br>        {<br>            a[i]</span><span style="color: #000000;">=-</span><span style="color: #000000;">1</span><span style="color: #000000;">;<br>            s</span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>            count</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>        }<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(i</span><span style="color: #000000;">==</span><span style="color: #000000;">N</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>            i</span><span style="color: #000000;">=-</span><span style="color: #000000;">1</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(s</span><span style="color: #000000;">==</span><span style="color: #000000;">N</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>            break;<br>        <br>    }<br>    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;">;<br>    </span><span style="color: #0000ff;">for</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;">N;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(a[i]!</span><span style="color: #000000;">=-</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>            cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">a[i];<br>    cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>    <br>    return </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}</span></div> <br><br> <img src ="http://www.shnenglu.com/heidaizx/aggbug/36868.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heidaizx/" target="_blank">heidaizx</a> 2007-11-18 14:42 <a href="http://www.shnenglu.com/heidaizx/articles/36868.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>闃熷垪瀹炵幇鏉ㄨ緣涓夎褰㈢畻娉曪紙闈為噾瀛楀褰級寰呮敼榪?/title><link>http://www.shnenglu.com/heidaizx/articles/35343.html</link><dc:creator>heidaizx</dc:creator><author>heidaizx</author><pubDate>Sun, 28 Oct 2007 07:28:00 GMT</pubDate><guid>http://www.shnenglu.com/heidaizx/articles/35343.html</guid><wfw:comment>http://www.shnenglu.com/heidaizx/comments/35343.html</wfw:comment><comments>http://www.shnenglu.com/heidaizx/articles/35343.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heidaizx/comments/commentRss/35343.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heidaizx/services/trackbacks/35343.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include</span><span style="color: #000000;">"</span><span style="color: #000000;">LinkedQueue.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>void YANGVI(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> n)<br>{<br>    LinkedQueue</span><span style="color: #000000;"><</span><span style="color: #0000ff;">int</span><span style="color: #000000;">></span><span style="color: #000000;"> q;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> k;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i</span><span style="color: #000000;">=</span><span style="color: #000000;">1</span><span style="color: #000000;">,j,s</span><span style="color: #000000;">=</span><span style="color: #000000;">k</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">,t,u;         </span><span style="color: #000000;">//</span><span style="color: #000000;">璁$畻涓嬩竴琛岀郴鏁版椂鐢ㄥ埌鐨勫伐浣滃崟鍏?br>    q.EnQueue(i);q.EnQueue(i);   </span><span style="color: #000000;">//</span><span style="color: #000000;">棰勫厛鏀懼叆絎竴琛岀殑涓や釜緋繪暟<br>    </span><span style="color: #0000ff;">for</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;">n;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>    {<br>        cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;              </span><span style="color: #000000;">//</span><span style="color: #000000;">鎹㈣<br>        q.EnQueue(k);             </span><span style="color: #000000;">//</span><span style="color: #000000;">鍚勮闂存彃鍏ヤ竴涓?<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(j</span><span style="color: #000000;">=</span><span style="color: #000000;">1</span><span style="color: #000000;">;j</span><span style="color: #000000;"><=</span><span style="color: #000000;">i</span><span style="color: #000000;">+</span><span style="color: #000000;">2</span><span style="color: #000000;">;j</span><span style="color: #000000;">++</span><span style="color: #000000;">)      </span><span style="color: #000000;">//</span><span style="color: #000000;">澶勭悊絎琲琛岀殑i</span><span style="color: #000000;">+</span><span style="color: #000000;">2涓郴鏁?鍖呮嫭涓涓?)<br>        {<br>            q.DeQueue(t);        </span><span style="color: #000000;">//</span><span style="color: #000000;">璇誨彇涓涓郴鏁?br>            u</span><span style="color: #000000;">=</span><span style="color: #000000;">s</span><span style="color: #000000;">+</span><span style="color: #000000;">t;              </span><span style="color: #000000;">//</span><span style="color: #000000;">璁$畻涓嬩竴琛岀殑緋繪暟<br>            q.EnQueue(u);        </span><span style="color: #000000;">//</span><span style="color: #000000;">榪涢槦鍒?br>            s</span><span style="color: #000000;">=</span><span style="color: #000000;">t;                </span><span style="color: #000000;">//</span><span style="color: #000000;">姣忔璁板綍鍒氭墠鍑洪槦鍒楃殑鍊鹼紝渚夸簬涓庝笅嬈″嚭闃熷垪鐨勫肩浉鍔?br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(j!</span><span style="color: #000000;">=</span><span style="color: #000000;">2</span><span style="color: #000000;">+</span><span style="color: #000000;">i) cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">s</span><span style="color: #000000;"><<</span><span style="color: #008000;">'</span><span style="color: #008000;"> ';//鎵撳嵃涓涓郴鏁幫紝絎琲+2涓槸0</span><span style="color: #008000;"><br></span><span style="color: #000000;">        }<br>    }<br>}</span></div> <br><img src ="http://www.shnenglu.com/heidaizx/aggbug/35343.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heidaizx/" target="_blank">heidaizx</a> 2007-10-28 15:28 <a href="http://www.shnenglu.com/heidaizx/articles/35343.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>寰幆闃熷垪鐨勯摼琛ㄨ〃紺?/title><link>http://www.shnenglu.com/heidaizx/articles/35337.html</link><dc:creator>heidaizx</dc:creator><author>heidaizx</author><pubDate>Sun, 28 Oct 2007 03:39:00 GMT</pubDate><guid>http://www.shnenglu.com/heidaizx/articles/35337.html</guid><wfw:comment>http://www.shnenglu.com/heidaizx/comments/35337.html</wfw:comment><comments>http://www.shnenglu.com/heidaizx/articles/35337.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heidaizx/comments/commentRss/35337.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heidaizx/services/trackbacks/35337.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include</span><span style="color: #000000;">"</span><span style="color: #000000;">LinkedList.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#include</span><span style="color: #000000;">"</span><span style="color: #000000;">Queue.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>class LinkedQueue<br>{<br></span><span style="color: #0000ff;">public</span><span style="color: #000000;">:<br>    LinkedQueue():rear(</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">),front(</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">){}<br>    ~LinkedQueue(){makeEmpty();}<br>    bool EnQueue(</span><span style="color: #0000ff;">const</span><span style="color: #000000;"> T</span><span style="color: #000000;">&</span><span style="color: #000000;"> x);<br>    bool DeQueue(T</span><span style="color: #000000;">&</span><span style="color: #000000;"> x);<br>    bool getFront(T</span><span style="color: #000000;">&</span><span style="color: #000000;"> x)</span><span style="color: #0000ff;">const</span><span style="color: #000000;">;<br>    void makeEmpty();<br>    bool </span><span style="color: #0000ff;">IsEmpty</span><span style="color: #000000;">()</span><span style="color: #0000ff;">const</span><span style="color: #000000;">{return(front</span><span style="color: #000000;">==</span><span style="color: #000000;">rear)?</span><span style="color: #0000ff;">true</span><span style="color: #000000;">:</span><span style="color: #0000ff;">false</span><span style="color: #000000;">;}<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> getSize()</span><span style="color: #0000ff;">const</span><span style="color: #000000;">;<br></span><span style="color: #000000;">//</span><span style="color: #000000;">    bool IsFull()</span><span style="color: #0000ff;">const</span><span style="color: #000000;">{return((rear</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">)%maxSize</span><span style="color: #000000;">==</span><span style="color: #000000;">front)?</span><span style="color: #0000ff;">true</span><span style="color: #000000;">:</span><span style="color: #0000ff;">false</span><span style="color: #000000;">;}<br>    friend ostream</span><span style="color: #000000;">&</span><span style="color: #000000;"> operator</span><span style="color: #000000;"><<</span><span style="color: #000000;">(ostream</span><span style="color: #000000;">&</span><span style="color: #000000;"> os,LinkedQueue</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">>&</span><span style="color: #000000;"> Q);  <br>protected:<br>    LinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">front, </span><span style="color: #000000;">*</span><span style="color: #000000;">rear;<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>void LinkedQueue</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::makeEmpty()<br>{<br>    LinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">p;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(front!</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">)<br>    {<br>        p</span><span style="color: #000000;">=</span><span style="color: #000000;">front;<br>        front</span><span style="color: #000000;">=</span><span style="color: #000000;">front</span><span style="color: #000000;">-></span><span style="color: #000000;">link;<br>        delete p;<br>    }<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>bool LinkedQueue</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::EnQueue(</span><span style="color: #0000ff;">const</span><span style="color: #000000;"> T</span><span style="color: #000000;">&</span><span style="color: #000000;"> x)<br>{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(front</span><span style="color: #000000;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">)<br>    {<br>        front</span><span style="color: #000000;">=</span><span style="color: #000000;">rear</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> LinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">(x);</span><span style="color: #000000;">//</span><span style="color: #000000;">絀洪槦鍒楁椂錛屾柊緇撶偣鎴愪負闃熷垪鐨勭涓涓粨鐐癸紝鏃㈡槸瀵瑰ご涔熸槸闃熷熬<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(front</span><span style="color: #000000;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">) return </span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>    }<br>    </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>    {<br>        rear</span><span style="color: #000000;">-></span><span style="color: #000000;">link</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> LinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">(x);</span><span style="color: #000000;">//</span><span style="color: #000000;">闈炵┖鏃跺湪閾懼熬榪藉姞鏂扮殑緇撶偣騫舵洿鏂伴槦灝炬寚閽?br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(rear</span><span style="color: #000000;">-></span><span style="color: #000000;">link</span><span style="color: #000000;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">) return </span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>        rear</span><span style="color: #000000;">=</span><span style="color: #000000;">rear</span><span style="color: #000000;">-></span><span style="color: #000000;">link;<br>    }<br>    return </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>bool LinkedQueue</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::DeQueue(T</span><span style="color: #000000;">&</span><span style="color: #000000;"> x)<br>{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #0000ff;">IsEmpty</span><span style="color: #000000;">()</span><span style="color: #000000;">==</span><span style="color: #0000ff;">true</span><span style="color: #000000;">) return </span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>    LinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">p</span><span style="color: #000000;">=</span><span style="color: #000000;">front;<br>    x</span><span style="color: #000000;">=</span><span style="color: #000000;">front</span><span style="color: #000000;">-></span><span style="color: #000000;">data;<br>    front</span><span style="color: #000000;">=</span><span style="color: #000000;">front</span><span style="color: #000000;">-></span><span style="color: #000000;">link;<br>    delete p;<br>    return </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>bool LinkedQueue</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::getFront(T</span><span style="color: #000000;">&</span><span style="color: #000000;"> x)</span><span style="color: #0000ff;">const</span><span style="color: #000000;"><br>{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #0000ff;">IsEmpty</span><span style="color: #000000;">()</span><span style="color: #000000;">==</span><span style="color: #0000ff;">true</span><span style="color: #000000;">) return </span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>    x</span><span style="color: #000000;">=</span><span style="color: #000000;">front</span><span style="color: #000000;">-></span><span style="color: #000000;">data;<br>    return </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> LinkedQueue</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;">::getSize()</span><span style="color: #0000ff;">const</span><span style="color: #000000;"><br>{<br>    LinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">p</span><span style="color: #000000;">=</span><span style="color: #000000;">front;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> k</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(p!</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">)<br>    {<br>        p</span><span style="color: #000000;">=</span><span style="color: #000000;">p</span><span style="color: #000000;">-></span><span style="color: #000000;">link;<br>        k</span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>    }<br>    return k;<br>};<br><br>template</span><span style="color: #000000;"><</span><span style="color: #000000;">class T</span><span style="color: #000000;">></span><span style="color: #000000;"><br>ostream</span><span style="color: #000000;">&</span><span style="color: #000000;"> operator</span><span style="color: #000000;"><<</span><span style="color: #000000;">(ostream</span><span style="color: #000000;">&</span><span style="color: #000000;"> os,LinkedQueue</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">>&</span><span style="color: #000000;"> Q)<br>{<br>    os</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;">Q.getSize()</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>    LinkNode</span><span style="color: #000000;"><</span><span style="color: #000000;">T</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">*</span><span style="color: #000000;">p</span><span style="color: #000000;">=</span><span style="color: #000000;">Q.front;<br>    </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;">;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(p!</span><span style="color: #000000;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">)<br>    {<br>        os</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;">:</span><span style="color: #000000;">"</span><span style="color: #000000;"><<</span><span style="color: #000000;">p</span><span style="color: #000000;">-></span><span style="color: #000000;">data</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>        p</span><span style="color: #000000;">=</span><span style="color: #000000;">p</span><span style="color: #000000;">-></span><span style="color: #000000;">link;<br>    }<br>    return os;<br>}<br></span></div> <br><img src ="http://www.shnenglu.com/heidaizx/aggbug/35337.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heidaizx/" target="_blank">heidaizx</a> 2007-10-28 11:39 <a href="http://www.shnenglu.com/heidaizx/articles/35337.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>寰幆闃熷垪鐨勬暟緇勮〃紺哄嚱鏁扮殑瀹炵幇http://www.shnenglu.com/heidaizx/articles/35335.htmlheidaizxheidaizxSun, 28 Oct 2007 02:41:00 GMThttp://www.shnenglu.com/heidaizx/articles/35335.htmlhttp://www.shnenglu.com/heidaizx/comments/35335.htmlhttp://www.shnenglu.com/heidaizx/articles/35335.html#Feedback0http://www.shnenglu.com/heidaizx/comments/commentRss/35335.htmlhttp://www.shnenglu.com/heidaizx/services/trackbacks/35335.html#include<assert.h>
#include
<iostream.h>
#include
<stdlib.h>
#include
"Queue.h"
template
<class T>
class SeqQueue
{
public:
    SeqQueue(
int sz=10);
    ~SeqQueue(){delete[]elements;}
    bool EnQueue(
const T& x);
    bool DeQueue(T
& x);
    bool getFront(T
& x);
    void makeEmpty(){front
=rear=0;}
    bool 
IsEmpty()const{return(front==rear)?true:false;}
    bool IsFull()
const{return((rear+1)%maxSize==front)?true:false;}
    friend ostream
& operator<<(ostream& os,SeqQueue<T>& Q);     //杈撳嚭閲嶈澆
protected:
    
int rear,front;              //闃熷熬鎸囬拡涓庡澶存寚閽?br>    T *elements;                 
    
int maxSize;                //闃熷垪鏈澶у彲瀹圭撼涓暟
};

template
<class T>
SeqQueue
<T>::SeqQueue(int sz):front(0),rear(0),maxSize(sz)
{
    elements
=new T[maxSize];
    assert(elements!
=NULL);
};

template
<class T>
bool SeqQueue
<T>::EnQueue(const T& x)
{
    
if(IsFull()==true) return false;          //闃熷垪婊★紝鎻掑叆澶辮觸
    elements[rear]
=x;                         //鎸夌収闃熷熬鎸囬拡鎸囩ず鎻掑叆浣嶇疆
    rear
=(rear+1)%maxSize;                    //闃熷熬鎸囬拡+1
    return 
true;
};

template
<class T>
bool SeqQueue
<T>::DeQueue(T& x)
{
    
if(IsEmpty()==true) return false;
    x
=elements[front];
    front
=(front+1)%maxSize;
    return 
true;

}

template
<class T>
bool SeqQueue
<T>::getFront(T& x)
{
    
if(IsEmpty()==true) return false;
    x
=elements[front];
    return 
true;
};

template
<class T>
ostream
& operator<<(ostream& os,SeqQueue<T>& Q)
{
    os
<<"front="<<Q.front<<",rear="<<Q.rear<<endl;
    
for(int i=Q.front;i!=Q.rear;i=(i+1)%maxSize)
        os
<<i<<":"<<Q.elements[i]<<endl;
    return os;
}



heidaizx 2007-10-28 10:41 鍙戣〃璇勮
]]>
鏍堝疄鐜癴ib綆楁硶http://www.shnenglu.com/heidaizx/articles/35334.htmlheidaizxheidaizxSun, 28 Oct 2007 02:39:00 GMThttp://www.shnenglu.com/heidaizx/articles/35334.htmlhttp://www.shnenglu.com/heidaizx/comments/35334.htmlhttp://www.shnenglu.com/heidaizx/articles/35334.html#Feedback0http://www.shnenglu.com/heidaizx/comments/commentRss/35334.htmlhttp://www.shnenglu.com/heidaizx/services/trackbacks/35334.html//FIB鏁板垪鐨勬爤瀹炵幇//
///////////////////
#include"LinkedStack.h"
#include<stdlib.h>
struct Node
{
    long n;
    int tag;
};

long Fibnacci(long n)                           
{                                           
    LinkedStack<Node> S;                   
    Node *w=new Node;    //鍒嗛厤鍔ㄦ佸唴瀛橈紝濡傛灉涓嶅垎閰嶅垯紼嬪簭閿欒                   
    if(w==NULL)                               
    {                                       
        cerr<<"鍒嗛厤鍐呭瓨澶辮!"<<endl;   
        exit(1);                           
    }                                       
    long sum=0;                               
    do
    {
        while(n>1)          //涓嶆柇鐨勫皢緇撴瀯浣撳帇鍏ユ爤
        {
            w->n=n;
            w->tag=1;
            S.Push(*w);
            n--;
        }
        sum=sum+n;
   
   
        while(S.IsEmpty()==false)
        {
            S.Pop(*w);
            if(w->tag==1)
            {
                w->tag=2;
                S.Push(*w);
                n=w->n-2;
                break;
            }
        }
    }while(S.IsEmpty()==false);
    return sum;
}


heidaizx 2007-10-28 10:39 鍙戣〃璇勮
]]>
姹夎濉旈棶棰?/title><link>http://www.shnenglu.com/heidaizx/articles/34279.html</link><dc:creator>heidaizx</dc:creator><author>heidaizx</author><pubDate>Mon, 15 Oct 2007 11:52:00 GMT</pubDate><guid>http://www.shnenglu.com/heidaizx/articles/34279.html</guid><wfw:comment>http://www.shnenglu.com/heidaizx/comments/34279.html</wfw:comment><comments>http://www.shnenglu.com/heidaizx/articles/34279.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heidaizx/comments/commentRss/34279.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heidaizx/services/trackbacks/34279.html</trackback:ping><description><![CDATA[緇堜簬鎼炴竻浜嗗畠鐨勮繃紼嬶紝浣嗘槸榪樻槸涓嶇煡閬撳叾涓紪鍐欑殑濂ュ錛屽啀浠旂粏鎯蟲兂涓轟粈涔堣榪欐牱<br> <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"><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.h</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: #0000ff">string</span><span style="COLOR: #000000">.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>void Hanoi(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n,char A,char B,char C);<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>void main()<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>    Hanoi(</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">,</span><span style="COLOR: #008000">'</span><span style="COLOR: #008000">A','B','C');</span><span style="COLOR: #008000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></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>void Hanoi(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n,char A,char B,char C)<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">if</span><span style="COLOR: #000000">(n</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/None.gif" align=top>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Move top disk from peg </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"> to peg </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">C</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    </span><span style="COLOR: #0000ff">else</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>        Hanoi(n</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,A,C,B);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Move top disk from peg </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"> to peg </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">C</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        Hanoi(n</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,B,A,C);<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> <img src ="http://www.shnenglu.com/heidaizx/aggbug/34279.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heidaizx/" target="_blank">heidaizx</a> 2007-10-15 19:52 <a href="http://www.shnenglu.com/heidaizx/articles/34279.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎷彿鍖歸厤闂http://www.shnenglu.com/heidaizx/articles/34217.htmlheidaizxheidaizxSun, 14 Oct 2007 09:01:00 GMThttp://www.shnenglu.com/heidaizx/articles/34217.htmlhttp://www.shnenglu.com/heidaizx/comments/34217.htmlhttp://www.shnenglu.com/heidaizx/articles/34217.html#Feedback0http://www.shnenglu.com/heidaizx/comments/commentRss/34217.htmlhttp://www.shnenglu.com/heidaizx/services/trackbacks/34217.html

void PrintMatchedPairs(char 
*expression)//////////////////////////////////////////////////////////鎷彿鍖歸厤綆楁硶
{
    linkedStack s;
    
int j,length=strlen(expression);
    
for(int i=1;i<=length;i++)
    {
        
if(expression[i-1]=='(') s.Push(i);
        else if(expression[i-1]==')')
        {
            
if(s.Pop(j)==true)
                cout
<<j<<"涓?/span>"<<i<<"鍖歸厤"<<endl;
            
else 
                cout
<<"娌℃湁涓庣"<<i<<"涓嫭鍙峰尮閰嶇殑宸︽嫭鍙?"<<endl;
        }
    }
    
while(s.isEmpty()==false)
    {
        s.Pop(j);
        cout
<<"娌℃湁涓庣"<<j<<"涓乏鎷彿鐩稿尮閰嶇殑鍙蟲嫭鍙?"<<endl;
    }
}





鍒漢鍐欑殑浠g爜
 
char stack[200];/*   鏍堢┖闂?nbsp;  */  
int  size=0;    /*   鍏ユ爤涓暟   */  
int PrintMatchedPairs(char *expression)
{
    
int i;
    
for(i=0;i<strlen(expression);i++)  
    {  
        
char c=expression[i];  

   
        
if(c=='('||c=='['||c=='{')   /*   閬囧埌宸︽嫭鍙?nbsp;  */ 
        {  
            stack[size]
=c;   /*   stack   push   */  
            size
++;  
        }  
         
        
else if(c==')')  /*   閬囧埌鍙蟲嫭鍙?nbsp;  */ 
        {  
         
            
if(size==0||stack[size-1]!='(')  /*   媯鏌?nbsp;  stack   鏈鍚庝竴涓槸鍚︽槸   '('   */  
            {
                size
=0;
                
return 0;
                
            }
            
else  
                size
--;   /*   stack   pop   */  
        }  
        
else if(c==']')  
        {  
                  
            
if(size==0||stack[size-1]!='[')  /*   媯鏌?nbsp;  stack   鏈鍚庝竴涓槸鍚︽槸   '['   */  
            {
                size
=0;
                
return 0
                
            }
            
else  
                size
--;   /*   stack   pop   */  
        }  
        
else if(c=='}')  
        {  
                 
            
if(size==0||stack[size-1]!='{')   /*   媯鏌?nbsp;  stack   鏈鍚庝竴涓槸鍚︽槸   '{'   */  
            {
                size
=0;
                
return 0;
                
            }
            
else  
                size
--;   /*   stack   pop   */  
        }  
    }  
   
    
if(size==0)  
        
return 1;  
    
else  
    {
    
        size
=0;
        
return 0;
    }

}


heidaizx 2007-10-14 17:01 鍙戣〃璇勮
]]>
鏍堢殑綆鍗曞疄鐜?/title><link>http://www.shnenglu.com/heidaizx/articles/34214.html</link><dc:creator>heidaizx</dc:creator><author>heidaizx</author><pubDate>Sun, 14 Oct 2007 07:17:00 GMT</pubDate><guid>http://www.shnenglu.com/heidaizx/articles/34214.html</guid><wfw:comment>http://www.shnenglu.com/heidaizx/comments/34214.html</wfw:comment><comments>http://www.shnenglu.com/heidaizx/articles/34214.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heidaizx/comments/commentRss/34214.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heidaizx/services/trackbacks/34214.html</trackback:ping><description><![CDATA[<p> </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">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">assert.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>using namespace 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>struct linkNode<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"> data;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    linkNode </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">link;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    linkNode(linkNode </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pre</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">NULL</span><span style="COLOR: #000000">):link(pre){}<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    linkNode(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> d,linkNode </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pre</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">NULL</span><span style="COLOR: #000000">):link(pre),data(d){}<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><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>class linkedStack<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">public</span><span style="COLOR: #000000">:<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    linkedStack():top(</span><span style="COLOR: #0000ff">NULL</span><span style="COLOR: #000000">){}<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    ~linkedStack(){makeEmpty();};<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    void Push(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">x);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    bool Pop(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">x);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> getTop(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">x)</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    bool </span><span style="COLOR: #0000ff">isEmpty</span><span style="COLOR: #000000">()</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> {return (top</span><span style="COLOR: #000000">==</span><span style="COLOR: #0000ff">NULL</span><span style="COLOR: #000000">)?</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">:</span><span style="COLOR: #0000ff">false</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"> getSize()</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    void makeEmpty();<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    void output();<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000">:<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    linkNode </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">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><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>void linkedStack::makeEmpty()<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>    linkNode </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(top!</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">NULL</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>        p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">top;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        top</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">top</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">link;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        delete p;<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><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>void linkedStack::Push(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">x)<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>    top</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> linkNode(x,top);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    assert(top!</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">NULL</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 src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>bool linkedStack::Pop(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">x)<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">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">isEmpty</span><span style="COLOR: #000000">()</span><span style="COLOR: #000000">==</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">) return </span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    linkNode </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">top;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    top</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">top</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">link;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    x</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">data;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    delete p;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    return </span><span style="COLOR: #0000ff">true</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 src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> linkedStack::getTop(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">x)</span><span style="COLOR: #0000ff">const</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">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">isEmpty</span><span style="COLOR: #000000">()</span><span style="COLOR: #000000">==</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">) return </span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    x</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">top</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">data;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    return x;<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">int</span><span style="COLOR: #000000"> linkedStack::getSize()</span><span style="COLOR: #0000ff">const</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>    linkNode </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">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"> i</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/None.gif" align=top>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(p!</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">NULL</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>        p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">link;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        i</span><span style="COLOR: #000000">++</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>    return i;<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>void linkedStack::output()<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>    linkNode </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">top;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(p!</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">NULL</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>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">data</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">link;<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><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"> menu()<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"> choice;<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>    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</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    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 src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    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 src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">榪斿洖鏍堥《鍏冪礌鐨勫鹼紝璇鋒寜3</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/None.gif" align=top>    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">姹傛爤鐨勫厓绱犱釜鏁幫紝璇鋒寜4</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/None.gif" align=top>    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 src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    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 src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">閫鍑猴紝璇鋒寜7</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    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</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<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>    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">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">choice;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    return choice;<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">int</span><span style="COLOR: #000000"> main()<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>    linkedStack obj;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    bool </span><span style="COLOR: #0000ff">exit</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">true</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"> choice</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">menu();<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        switch(choice)<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">case</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/None.gif" align=top>            </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> s;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            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">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">s;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            obj.Push(s);break;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</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"> x;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            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">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">x;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">obj.Pop(x)</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;break;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">3</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"> y;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            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">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">y;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">obj.getTop(y)</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;break;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">:<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">obj.getSize()</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;break;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">:<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            obj.makeEmpty();break;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">:<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            obj.output();break;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>        </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">:<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            </span><span style="COLOR: #0000ff">exit</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;break;<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">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">exit</span><span style="COLOR: #000000">==</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">)<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>            break;<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>    return </span><span style="COLOR: #000000">0</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 src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span></div> <img src ="http://www.shnenglu.com/heidaizx/aggbug/34214.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heidaizx/" target="_blank">heidaizx</a> 2007-10-14 15:17 <a href="http://www.shnenglu.com/heidaizx/articles/34214.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.verywin.cn" target="_blank">亚洲国产日韩欧美久久</a>| <a href="http://www.abctoy.com.cn" target="_blank">久久国产精品波多野结衣AV</a>| <a href="http://www.panda-pc.cn" target="_blank">国产激情久久久久影院</a>| <a href="http://www.cjubbs.cn" target="_blank">97久久超碰国产精品2021</a>| <a href="http://www.sowudi.com.cn" target="_blank">久久人爽人人爽人人片AV</a>| <a href="http://www.8x8z.cn" target="_blank">少妇无套内谢久久久久</a>| <a href="http://www.angcao.cn" target="_blank">久久99热这里只有精品国产</a>| <a href="http://www.pluv.cn" target="_blank">欧美国产成人久久精品</a>| <a href="http://www.sank.net.cn" target="_blank">97精品国产97久久久久久免费 </a>| <a href="http://www.hkjiajiao.com.cn" target="_blank">亚洲国产成人久久精品99 </a>| <a href="http://www.bilili.com.cn" target="_blank">区久久AAA片69亚洲</a>| <a href="http://www.jdjx168.cn" target="_blank">性做久久久久久久久久久</a>| <a href="http://www.jsykszn.cn" target="_blank">欧美久久久久久</a>| <a href="http://www.wcxkmm.cn" target="_blank">狼狼综合久久久久综合网</a>| <a href="http://www.tv81.cn" target="_blank">国产精品久久久福利</a>| <a href="http://www.oxygeniclife.com.cn" target="_blank">青青热久久综合网伊人</a>| <a href="http://www.mir155.cn" target="_blank">久久精品国产亚洲7777</a>| <a href="http://www.diy800.cn" target="_blank">偷窥少妇久久久久久久久</a>| <a href="http://www.taskbee.cn" target="_blank">久久久久人妻一区二区三区vr</a>| <a href="http://www.galidun.cn" target="_blank">久久综合九色综合网站</a>| <a href="http://www.k1877.cn" target="_blank">伊人久久大香线焦综合四虎</a>| <a href="http://www.uovd.cn" target="_blank">久久精品无码免费不卡</a>| <a href="http://www.010law.cn" target="_blank">99久久国产综合精品女同图片</a>| <a href="http://www.sunyu-display.cn" target="_blank">日韩精品久久无码中文字幕</a>| <a href="http://www.oysport.cn" target="_blank">一级做a爰片久久毛片16</a>| <a href="http://www.lzjrdfl.cn" target="_blank">亚洲国产精品无码久久青草</a>| <a href="http://www.dqcz.net.cn" target="_blank">日本久久久久亚洲中字幕</a>| <a href="http://www.dysky.cn" target="_blank">久久最近最新中文字幕大全</a>| <a href="http://www.tthzk.cn" target="_blank">三级韩国一区久久二区综合</a>| <a href="http://www.huiju365.cn" target="_blank">久久久亚洲欧洲日产国码二区</a>| <a href="http://www.kangle.net.cn" target="_blank">久久96国产精品久久久</a>| <a href="http://www.a2302.cn" target="_blank">亚洲精品97久久中文字幕无码</a>| <a href="http://www.37114.cn" target="_blank">国产亚洲综合久久系列</a>| <a href="http://www.gpshd.cn" target="_blank">日韩影院久久</a>| <a href="http://www.xiatiancaiwu.cn" target="_blank">9999国产精品欧美久久久久久</a>| <a href="http://www.gofiv.cn" target="_blank">久久久午夜精品</a>| <a href="http://www.nuopie.cn" target="_blank">色偷偷888欧美精品久久久</a>| <a href="http://www.chengzhangtixi.cn" target="_blank">久久亚洲AV无码精品色午夜麻豆</a>| <a href="http://www.chuangwote.com.cn" target="_blank">99re久久精品国产首页2020</a>| <a href="http://www.jinlvyu1.cn" target="_blank">人妻无码精品久久亚瑟影视</a>| <a href="http://www.wldyl.com.cn" target="_blank">久久99精品国产99久久6男男</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>