• <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}
            国色天香久久久久久久小说| 久久96国产精品久久久| 久久久久无码国产精品不卡| 精品无码久久久久久久久久| 国产欧美久久久精品影院| 亚洲精品乱码久久久久久久久久久久 | 亚洲?V乱码久久精品蜜桃 | 少妇高潮惨叫久久久久久| 9久久9久久精品| 一级做a爰片久久毛片毛片| 99久久人妻无码精品系列| 久久久久亚洲精品无码网址| 久久久久无码精品国产| 亚洲Av无码国产情品久久| 久久精品这里热有精品| 奇米影视7777久久精品人人爽| 99久久超碰中文字幕伊人| 久久久久se色偷偷亚洲精品av| 国产成人久久777777| 久久午夜无码鲁丝片| 亚洲国产成人乱码精品女人久久久不卡| 久久久久无码精品国产不卡| 久久久精品国产免大香伊| 久久精品无码一区二区日韩AV| www性久久久com| MM131亚洲国产美女久久| 久久精品中文闷骚内射| 久久无码国产专区精品| 亚洲国产视频久久| 久久久久久久久久免免费精品| 久久久久久久综合日本亚洲| 色欲av伊人久久大香线蕉影院| 一本色综合久久| 久久强奷乱码老熟女网站| 亚洲午夜无码AV毛片久久| 久久不见久久见免费影院www日本| 一本大道久久a久久精品综合| 久久国产精品一区二区| 久久免费精品一区二区| 丁香久久婷婷国产午夜视频| 91久久精品国产91性色也|