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

            ArcTan

            dfs
            隨筆 - 16, 文章 - 117, 評論 - 6, 引用 - 0
            數據加載中……

            hdu 2093(結構體排序 水題哇哇哇)

            hdu 2093
            結構體排序
            struct student
            {
                  char name[20];
                  int AC,time;
            }
            首先按照AC,time,如果前兩個都相同就按照name的字典序排序。

            這個讀入很簡單,sscanf();這個函數還不會用。

            輸出需要名字占10,靠左,則用“%-10s”

            直接貼代碼:WA了一次,中間調試輸出的東西忘記刪除了。
            總結:字符串類題目還是要自己做做,雖然有些很惡心,惡心兩次就好了!哈哈,

            #include<stdio.h>
            #include
            <string.h>
            #include
            <math.h>
            struct student
            {
                
            char name[20];
                
            int AC,time;
            } p[
            1005],temp,tt;

            int tot;

            int cmp(student a,student b)  
            {
                
            if (a.AC>b.AC)
                    
            return 1;
                
            if (a.AC==b.AC&&a.time<b.time)
                    
            return 1;
                
            int i=0;
                
            while (a.AC==b.AC&&a.time==b.time&&i<strlen(a.name)&&i<strlen(b.name))
                {
                    
            if (a.name[i]<b.name[i])
                        
            return 1;
                    i
            ++;
                }
                
            return 0;
            }

            int qsort(int l,int r)      //自己還是不習慣條用stl里的sort()
            {
                
            int i,j;
                i
            =l;
                j
            =r;
                temp
            =p[(i+j)/2];
                
            while (i<=j)
                {
                    
            while (i<=j&&cmp(p[i],temp))    i++;
                    
            while (i<=j&&cmp(temp,p[j]))    j--;
                    
            if (i<=j)
                    {
                        tt
            =p[i];
                        p[i]
            =p[j];
                        p[j]
            =tt;
                        i
            ++;
                        j
            --;
                    }
                }
                
            if (l<j)    qsort(l,j);
                
            if (i<r)    qsort(i,r);
                
            return 0;
            }

            int main()
            {
                
            int n,m,i,j,tmp;
                
            char ch;
                scanf(
            "%d%d",&n,&m);
                tot
            =0;
                
            while (scanf("%s",&p[0].name)==1&&p[0].name[0]!='0')
                {
                    tot
            ++;
                    p[tot]
            =p[0];
                    p[tot].AC
            =0;
                    p[tot].time
            =0;
                    
            for (i=1; i<=n ; i++ )
                    {
                        scanf(
            "%d",&tmp);
                        
            if (tmp>0)
                        {
                            p[tot].AC
            ++;
                            p[tot].time
            +=tmp;
                            ch
            =getchar();
                            
            if (ch=='(')
                            {
                                scanf(
            "%d",&tmp);
                                p[tot].time
            +=m*tmp;
                                getchar();
                            }
                        }
                    }
                }

                qsort(
            1,tot);

                
            for (i=1; i<=tot ; i++ )
                {

                    printf(
            "%-10s %2d %4d\n",p[i].name,p[i].AC,p[i].time);
                }
                
            return 0;
            }

            posted on 2012-06-07 15:07 wangs 閱讀(579) 評論(0)  編輯 收藏 引用 所屬分類: ACM-水題

            中文字幕日本人妻久久久免费| 国产香蕉久久精品综合网| 国产亚洲综合久久系列| 国产精品一区二区久久不卡| 久久夜色tv网站| 亚洲色大成网站www久久九| 成人免费网站久久久| 国产精自产拍久久久久久蜜| 亚洲精品综合久久| 亚洲国产精品婷婷久久| 色综合久久中文字幕无码| 精品久久综合1区2区3区激情| 精品久久亚洲中文无码| 久久99精品久久久久久不卡| 久久久久亚洲Av无码专| 亚洲精品99久久久久中文字幕| 狠狠狠色丁香婷婷综合久久俺| 欧美亚洲国产精品久久| 国产精品美女久久久久av爽 | 亚洲色婷婷综合久久| 久久久久黑人强伦姧人妻| 97久久精品国产精品青草| 亚洲中文字幕无码久久2017| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久久久久久久久久| 久久综合一区二区无码| 久久噜噜电影你懂的| 久久夜色精品国产噜噜亚洲AV| 久久婷婷五月综合97色直播| 一本久久综合亚洲鲁鲁五月天| 国产精品综合久久第一页| 久久99精品久久久久久野外| 一本一道久久精品综合| 99久久无码一区人妻| 久久亚洲国产中v天仙www| 亚洲天堂久久精品| 国产视频久久| 一本久久a久久精品综合香蕉| 一本久久综合亚洲鲁鲁五月天| 久久国产免费直播| 国内精品伊人久久久久av一坑|