• <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 閱讀(272) 評論(0)  編輯 收藏 引用 所屬分類: POJ
            此程序耗費我盡3個小時之久,原因是做題前的規(guī)劃沒做好,一直沒有想到整體排序的好辦法,最后還是用了注意匹配的方法才解決了問題,我不知道為什么用冒泡不行,第一個字符串總是亂碼。我覺得整體思路還是比較清晰的,只是方法可能有點傻,效率還行。
            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]; // 存儲字符串
            POJ 1007 DNA sorting - Icho - Brian Warehouse
                int count[2]; // [0] [1]都存放串的逆序數(shù) 
            POJ 1007 DNA sorting - Icho - Brian Warehouse
            }
            DNA;              // [1]中作為參考,用來和排序后的[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++// 對于各組串的逆序數(shù)進行排序,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    }
                            // 這是典型的選擇排序,只是對[0]單元的處理,穩(wě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// 此步是相等時順序不變的保證,相當于做了訪問標記!
            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}
            亚洲国产精品一区二区久久| 99久久久久| 久久久久久久久久久精品尤物| 久久久久久久女国产乱让韩| 久久国产精品99久久久久久老狼 | 久久久久人妻精品一区三寸蜜桃 | 久久久久久免费视频| 丰满少妇高潮惨叫久久久| 国产免费久久久久久无码| 中文字幕日本人妻久久久免费| 青青青伊人色综合久久| 伊人 久久 精品| 久久国产乱子伦精品免费午夜| 久久午夜羞羞影院免费观看| 怡红院日本一道日本久久 | 久久天天躁狠狠躁夜夜网站| 久久久久99精品成人片牛牛影视 | 精品久久国产一区二区三区香蕉| 国内精品久久久久久久久电影网| 久久精品国产亚洲av瑜伽| 久久国产精品久久| 久久久久国产精品熟女影院| 久久久无码精品亚洲日韩京东传媒 | 久久久精品波多野结衣| 色综合久久久久网| 国产亚洲美女精品久久久久狼| 国内精品久久久久影院薰衣草| 日日狠狠久久偷偷色综合免费| 国产一区二区精品久久岳| 99久久国产主播综合精品| 成人午夜精品久久久久久久小说| 久久久中文字幕| 国产精品久久久久一区二区三区| 欧美久久综合性欧美| 国产午夜电影久久| 日本久久久久久久久久| 久久亚洲色一区二区三区| 亚洲人成无码www久久久| 欧美精品福利视频一区二区三区久久久精品| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 婷婷久久综合九色综合九七|