• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            just Programme

            編程是個很長的路程
            posts - 0, comments - 2, trackbacks - 0, articles - 2
              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            //Jose.cpp----使用單向循環(huán)鏈表實現(xiàn)約瑟夫問題
            //問題描述:n個人手拉手排成一個環(huán),從第一個人開始數(shù),每數(shù)到第m個人,第m個人出列,從下一人重新計數(shù)重新數(shù),求全部出列后他們的出列順序
            #include <iostream.h>
            struct jose
            {
            ?int data;
            ?int no;
            ?struct jose * next;
            };

            int main()
            {
            ?struct jose *head,*p_curent,*p_find;
            ?int n,m;
            ?cout << "Please enter the total of numbers (n):";
            ?cin >> n;
            ?cout << "Please enter the counter number (m):";
            ?cin >> m;
            ?
            ?//初始化鏈表
            ?head=p_curent=new jose;//標記首表元地址,即頭指針
            ?head->no=1;
            ?cout << "Please enter the first number :";
            ?cin >>head->data;
            ?//形成其余的n-1表元
            ?cout << "Please enter last numbers :"<<endl;
            ?for (int i=2;i<=n;i++)
            ?{
            ??p_curent->next=new jose;
            ??p_curent=p_curent->next;
            ??cin >> p_curent->data;
            ??p_curent->no=i;
            ?}//end for
            ?p_curent->next=head;//尾指針指向頭指針,形成環(huán),到這完成初始化鏈表

            ?//開始查詢,第M個人出列,并輸出
            ?cout << "Now : The? numbers of who will quit the cycle in turn are:"<<endl;
            ?while (n)//全部出列后結(jié)束循環(huán)
            ?{
            ??//掠過m-1個表元
            ??for (int j=1;j<m;j++)
            ???p_curent=p_curent->next;//end?for
            ??//找到第M個人
            ??p_find=p_curent->next;
            ??//從表中刪除第m個人,并輸出第m個人
            ??p_curent->next=p_find->next;
            ??cout << p_find->data<<endl;
            ??//釋放第m個表元占用的空間
            ??delete p_find;
            ??n--;
            ?}
            ?//end while
            ?
            ?return 0;
            }

            Feedback

            # re: 使用單向循環(huán)鏈表實現(xiàn)約瑟夫問題  回復(fù)  更多評論   

            2010-04-01 23:52 by 郝竹林
            你這個程序不算完美 看看我寫的 http://blog.renren.com/blog/316635779/454822169
            国产真实乱对白精彩久久| 久久中文字幕视频、最近更新 | 久久五月精品中文字幕| 四虎影视久久久免费观看| 99久久夜色精品国产网站| 精品一区二区久久久久久久网站| 欧美成a人片免费看久久| 久久久亚洲欧洲日产国码二区 | 伊人色综合九久久天天蜜桃 | 一极黄色视频久久网站| 99国产欧美久久久精品蜜芽| 亚洲精品无码久久久久AV麻豆| 国产精品久久久久国产A级| 欧美久久一区二区三区| 91久久香蕉国产熟女线看| 国产亚洲美女精品久久久2020| 岛国搬运www久久| 天堂久久天堂AV色综合| 久久久这里有精品| 久久精品中文字幕一区| 久久―日本道色综合久久| 无码人妻少妇久久中文字幕蜜桃| 久久精品国产欧美日韩| 久久电影网2021| 国产综合久久久久久鬼色| 久久久精品国产sm调教网站| 久久精品国产99国产精品导航| 日日狠狠久久偷偷色综合96蜜桃| 日本三级久久网| 久久国产乱子伦精品免费强| 日产精品99久久久久久| 亚洲av伊人久久综合密臀性色| 伊人色综合九久久天天蜜桃| 一本久久a久久精品综合香蕉| 久久综合九色综合欧美就去吻| 国产成人精品综合久久久| 久久91精品国产91久久小草 | 亚洲午夜久久久影院| 国产激情久久久久久熟女老人| 亚洲七七久久精品中文国产| 久久天天躁狠狠躁夜夜2020老熟妇|