• <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>

            Brian Warehouse

            Some birds aren`t meant to be caged, their feathers are just too bright... ...
            posts - 40, comments - 16, trackbacks - 0, articles - 1

            POJ 1007 DNA sorting

            Posted on 2010-08-17 14:12 Brian 閱讀(264) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): POJ
            此程序耗費(fèi)我盡3個(gè)小時(shí)之久,原因是做題前的規(guī)劃沒(méi)做好,一直沒(méi)有想到整體排序的好辦法,最后還是用了注意匹配的方法才解決了問(wèn)題,我不知道為什么用冒泡不行,第一個(gè)字符串總是亂碼。我覺(jué)得整體思路還是比較清晰的,只是方法可能有點(diǎn)傻,效率還行。
            C 編譯器 : 172K    0MS
            POJ 1007 DNA sorting - Icho - Brian Warehouse#include <stdio.h>
            POJ 1007 DNA sorting - Icho - Brian Warehouse#include 
            <string.h>
            POJ 1007 DNA sorting - Icho - Brian Warehouse
            POJ 1007 DNA sorting - Icho - Brian Warehousetypedef 
            struct DNA
            POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
            POJ 1007 DNA sorting - Icho - Brian Warehouse{
            POJ 1007 DNA sorting - Icho - Brian Warehouse    
            char str[50]; // 存儲(chǔ)字符串
            POJ 1007 DNA sorting - Icho - Brian Warehouse
                int count[2]; // [0] [1]都存放串的逆序數(shù) 
            POJ 1007 DNA sorting - Icho - Brian Warehouse
            }
            DNA;              // [1]中作為參考,用來(lái)和排序后的[0]匹配
            POJ 1007 DNA sorting - Icho - Brian Warehouse

            POJ 1007 DNA sorting - Icho - Brian Warehouse
            int main()
            POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
            POJ 1007 DNA sorting - Icho - Brian Warehouse{
            POJ 1007 DNA sorting - Icho - Brian Warehouse    
            int i=0,j,k=0,n,m,temp;
            POJ 1007 DNA sorting - Icho - Brian Warehouse    DNA or[
            100];
            POJ 1007 DNA sorting - Icho - Brian Warehouse    scanf(
            "%d%d",&n,&m);
            POJ 1007 DNA sorting - Icho - Brian Warehouse    
            POJ 1007 DNA sorting - Icho - Brian Warehouse    
            while (k<m) //獲得數(shù)據(jù)并求各自逆序數(shù)
            POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
                POJ 1007 DNA sorting - Icho - Brian Warehouse{
            POJ 1007 DNA sorting - Icho - Brian Warehouse        scanf(
            "%s",&or[k].str);
            POJ 1007 DNA sorting - Icho - Brian Warehouse        or[k].count[
            0]=0// 此步不能忘
            POJ 1007 DNA sorting - Icho - Brian Warehouse
                    for (i=0; i<n; i++)
            POJ 1007 DNA sorting - Icho - Brian Warehouse            
            for (j=i+1; j<n; j++)
            POJ 1007 DNA sorting - Icho - Brian Warehouse                
            if (or[k].str[i] > or[k].str[j])
            POJ 1007 DNA sorting - Icho - Brian Warehouse                    or[k].count[
            0]++;
            POJ 1007 DNA sorting - Icho - Brian Warehouse        k
            ++;
            POJ 1007 DNA sorting - Icho - Brian Warehouse    }

            POJ 1007 DNA sorting - Icho - Brian Warehouse    
            POJ 1007 DNA sorting - Icho - Brian Warehouse    
            for (i=0; i<m; i++)
            POJ 1007 DNA sorting - Icho - Brian Warehouse        or[i].count[
            1]=or[i].count[0]; // 原逆序數(shù)存放順序
            POJ 1007 DNA sorting - Icho - Brian Warehouse

            POJ 1007 DNA sorting - Icho - Brian Warehouse    
            for (i=1; i<m; i++// 對(duì)于各組串的逆序數(shù)進(jìn)行排序,count[0]內(nèi)容已打亂
            POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
                POJ 1007 DNA sorting - Icho - Brian Warehouse{
            POJ 1007 DNA sorting - Icho - Brian Warehouse        k
            =i-1;
            POJ 1007 DNA sorting - Icho - Brian Warehouse        
            for (j=i; j<m; j++)
            POJ 1007 DNA sorting - Icho - Brian Warehouse            
            if (or[j].count[0< or[k].count[0])
            POJ 1007 DNA sorting - Icho - Brian Warehouse                k
            =j;
            POJ 1007 DNA sorting - Icho - Brian Warehouse        
            POJ 1007 DNA sorting - Icho - Brian Warehouse        temp
            =or[i-1].count[0];
            POJ 1007 DNA sorting - Icho - Brian Warehouse        or[i
            -1].count[0]=or[k].count[0];
            POJ 1007 DNA sorting - Icho - Brian Warehouse        or[k].count[
            0]=temp;
            POJ 1007 DNA sorting - Icho - Brian Warehouse    }
                            // 這是典型的選擇排序,只是對(duì)[0]單元的處理,穩(wěn)定與否沒(méi)關(guān)系
            POJ 1007 DNA sorting - Icho - Brian Warehouse
              
            POJ 1007 DNA sorting - Icho - Brian Warehouse
            POJ 1007 DNA sorting - Icho - Brian Warehouse    
            for (i=0; i<m; i++)
            POJ 1007 DNA sorting - Icho - Brian Warehouse        
            for (j=0; j<m; j++)
            POJ 1007 DNA sorting - Icho - Brian Warehouse            
            if (or[i].count[0== or[j].count[1]) // [0] 和 [1] 中逐一相比較
            POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
                        POJ 1007 DNA sorting - Icho - Brian Warehouse{
            POJ 1007 DNA sorting - Icho - Brian Warehouse                or[j].count[
            1]=-1// 此步是相等時(shí)順序不變的保證,相當(dāng)于做了訪問(wèn)標(biāo)記!
            POJ 1007 DNA sorting - Icho - Brian Warehouse
                            printf("%s\n",or[j].str);
            POJ 1007 DNA sorting - Icho - Brian Warehouse            }

            POJ 1007 DNA sorting - Icho - Brian Warehouse
            POJ 1007 DNA sorting - Icho - Brian Warehouse    
            return 0;
            POJ 1007 DNA sorting - Icho - Brian Warehouse}
            久久中文娱乐网| 嫩草伊人久久精品少妇AV| 久久国产成人精品麻豆| 国产精品欧美亚洲韩国日本久久| 国内精品久久国产| 精品久久久久久国产| 99久久国产免费福利| 亚洲色欲久久久久综合网| 久久精品aⅴ无码中文字字幕重口| 国产亚洲精久久久久久无码77777| 欧美精品福利视频一区二区三区久久久精品 | 亚洲国产日韩综合久久精品| A级毛片无码久久精品免费| 国产成人无码精品久久久免费 | 久久精品国产91久久综合麻豆自制| 久久久久免费精品国产| 久久久久久亚洲精品无码| 亚洲国产精品久久电影欧美| 久久久精品国产亚洲成人满18免费网站| 久久国产精品无码一区二区三区| 夜夜亚洲天天久久| 久久天天躁狠狠躁夜夜不卡| 国产激情久久久久影院小草 | 精品久久久久一区二区三区| 国产69精品久久久久9999APGF| 国产一区二区精品久久凹凸| 性色欲网站人妻丰满中文久久不卡| 国产精品无码久久久久| 久久久久99精品成人片欧美 | 国产Av激情久久无码天堂| 午夜精品久久久内射近拍高清| 中文字幕亚洲综合久久2| 麻豆成人久久精品二区三区免费| 久久免费视频6| 久久久国产精品网站| 国产亚洲美女精品久久久久狼| 精品熟女少妇av免费久久| 大香伊人久久精品一区二区| 色综合合久久天天给综看| 午夜精品久久久内射近拍高清 | .精品久久久麻豆国产精品|