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

            哇哦~這就是我

            This is my way ~
            <2008年3月>
            2425262728291
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            統(tǒng)計(jì)

            • 隨筆 - 10
            • 文章 - 0
            • 評(píng)論 - 2
            • 引用 - 0

            常用鏈接

            留言簿(1)

            隨筆檔案

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            C++第四次作業(yè)(統(tǒng)計(jì))
            #include<iostream>
            #include
            <string>
            #include
            <iomanip>
            #include
            <vector>
            #include
            <algorithm>
            const int MAXN=100;
            using namespace std;
            int cmp ( const void* p1 , const void *p2 )
            {
                return 
            *double* )p1>*(double*)p2?1:-1;
            }
            typedef struct COLOR
            {
                
            string col;
                
            double mean,median,sum,value[MAXN];
                
            int num,p;
            }COL;
            int find ( vector<COL> &str , COL s )
            {
                
            for ( vector<COL>::size_type i = 0; i != str.size(); i++ )
                    
            if ( str[i].col==s.col )
                    {
                        str[i].sum
            +=s.sum;
                        str[i].num
            ++;
                        str[i].value[str[i].p
            ++]=s.sum;
                        return 
            1;
                    }
                return 
            0;
            }
            void add ( vector
            <COL>& str , COL s )
            {
                
            if ( !find ( str , s ) )
                {
                    s.p
            =1;
                    s.num
            =1;
                    s.value[
            0]=s.sum;
                    str.push_back(s);
                }
            }
            void output ( vector
            <COL> str )
            {
                
            double s=0,v[MAXN],median;
                
            int n=0,q,j=0;
                
            for (vector<COL>::size_type i = 0; i != str.size(); ++i )
                {
                    
            for (q=0 ; q<str[i].p ; q++)
                        v[j
            ++]=str[i].value[q];
                    s
            +=str[i].sum;
                    n
            +=str[i].p;
                    qsort(str[i].value,str[i].num,sizeof(str[i].value[
            0]),cmp);
                    
            if (str[i].num%2)
                        str[i].median
            =str[i].value[(str[i].num-1)/2];
                    
            else
                        str[i].median
            =(str[i].value[str[i].num/2]+str[i].value[str[i].num/2-1])/2;
                    cout
            <<str[i].col<<"\t"<<""<<"sum="<<"\t"
                        
            <<setw(10)<<str[i].sum<<"\t"<<"mean="<<"\t"
                        
            <<setw(10)<<str[i].sum/str[i].num<<"\t"<<"median="<<"\t"
                        
            <<setw(10)<<str[i].median<<endl;
                        
                    
            /*
                    
            for ( int j=0 ; j<str[i].p ; j++ )
                        cout
            <<str[i].value[j]<<endl;
                        
            */
                }
                qsort(v,j,sizeof(v[
            0]),cmp);
                
            if (n%2!=0)
                    median
            =v[(n-1)/2];
                
            else
                    median
            =(v[n/2]+v[n/2-1])/2;
                
                cout
            <<"============================================================================"<<endl;
                cout
            <<"ALL"<<"\t"<<""<<"sum="<<"\t"
                    
            <<setw(10)<<s<<"\t"<<"mean="<<"\t"
                    
            <<setw(10)<<s/n<<"\t"<<"median="<<"\t"
                    
            <<setw(10)<<median<<endl;
                
            /*
                
            for ( j=0 ; j<n ;j++ )
                    cout
            <<v[j]<<endl;
                    
            */
            }
            int main ( )
            {
                vector
            <COL> str;
                COL s;
                
            while ( cin>>s.col>>s.sum )
                {
                    add(str,s);
                }
                output( str );
            }

            posted on 2008-03-27 17:24 chinaeli 閱讀(219) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            国产产无码乱码精品久久鸭| 久久久久综合国产欧美一区二区| 色综合久久无码中文字幕| 久久久久久九九99精品| 国产成人精品久久综合| AV无码久久久久不卡蜜桃| 精品视频久久久久| 精品少妇人妻av无码久久| 久久久青草青青国产亚洲免观| 一本一本久久A久久综合精品 | 99精品国产免费久久久久久下载 | 久久久噜噜噜www成人网| 久久se这里只有精品| 久久精品免费观看| 精品国产乱码久久久久久人妻| 久久国产精品波多野结衣AV| 久久香综合精品久久伊人| 波多野结衣久久精品| 日本精品久久久久影院日本| 色综合久久天天综合| 国产成人久久AV免费| 久久这里只有精品18| 久久精品一本到99热免费| 色综合合久久天天给综看| 久久久WWW成人免费毛片| 国内精品久久久久久久亚洲| 97久久综合精品久久久综合| 久久精品国产亚洲AV高清热 | 伊人色综合久久| 91精品国产综合久久香蕉| 久久精品中文字幕久久| 久久久久四虎国产精品| 久久国产精品久久精品国产| 久久精品成人免费看| 日本精品久久久久中文字幕8| 久久99精品国产99久久| 精品久久香蕉国产线看观看亚洲| 91精品国产综合久久久久久| 久久精品成人免费看| 久久久久久免费一区二区三区| 99久久婷婷国产一区二区|