C++实用模板 | 党办大活动计分

#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <fstream>
#include <map>
using namespace std;

struct A
{
    int num;
    float sc;
}d[10];

bool cmp(A t1,A t2)
{
    return (t1.sc>t2.sc);
}

int main()
{
    float a,b,c,t;
    int i=0,N=8;//评委总数
    while(cin>>b&&b)
    {//先输入每组大众评审票数,再依次输入评委分数,输入零结束输入
        a=0;//评委分数和
        for(int j=0;j<N;j++)
        {
            cin>>t;
            a+=t;
        }
        a=a/N;
        i++;
        c=a*0.7+b;
        cout<<c<<endl;
        d[i].num=i;
        d[i].sc=c;
    }
    sort(d+1,d+1+7,cmp);
    cout<<"排名"<<endl;
    for(int j=1;j<=7;j++)
    {
        cout<<d[j].num<<" "<<d[j].sc<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/tsj816523/p/11068607.html