508 条题解

  • 0
    @ 2017-12-18 15:29:08

    /*输入的第一行是一个整数N(1 <= N <= 100),表示学生的总数。
    接下来的N行每行是一位学生的数据,从左向右依次是姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,以及发表的论文数。
    姓名是由大小写英文字母组成的长度不超过20的字符串(不含空格);
    期末平均成绩和班级评议成绩都是0到100之间的整数(包括0和100);
    是否是学生干部和是否是西部省份学生分别用一个字符表示,Y表示是,N表示不是;
    发表的论文数是0到10的整数(包括0和10)。每两个相邻数据项之间用一个空格分隔。
    1) 院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发表1篇或1篇以上论文的学生均可获得;@
    2) 五四奖学金,每人4000元,期末平均成绩高于85分(>85),并且班级评议成绩高于80分(>80)的学生均可获得;@
    3) 成绩优秀奖,每人2000元,期末平均成绩高于90分(>90)的学生均可获得;@
    4) 西部奖学金,每人1000元,期末平均成绩高于85分(>85)的西部省份学生均可获得;
    5) 班级贡献奖,每人850元,班级评议成绩高于80分(>80)的学生干部均可获得;
    只要符合条件就可以得奖,每项奖学金的获奖人数没有限制,每名学生也可以同时获得多项奖学金。*/

    #include <iostream>
    #include <algorithm>
    using namespace std;
    struct prize
    {
    string name; //姓名
    double final_exam; //期末成绩
    double evaluation_exam;//评测成绩
    char class_leader; //是否为班干
    char west; //是否为西部省份学生
    int paper; //发表过的论文数
    int money=0; //奖学金
    };

    bool cmp(prize a, prize b)//比较函数
    {
    return a.money < b.money; //指明按照古董重量升序排列
    }
    int main()
    {
    int N;
    cin>>N;
    struct prize num[N];
    for(int i=0;i<N;i++)
    {
    cin>>num[i].name>>num[i].final_exam>>num[i].evaluation_exam>>num[i].class_leader>>num[i].west>>num[i].paper;
    if(num[i].final_exam>80&&num[i].paper>=1)num[i].money+=8000; //院士奖学金
    if(num[i].final_exam>90)num[i].money+=2000; //成绩优秀奖
    if(num[i].final_exam>85&&num[i].evaluation_exam>80)num[i].money+=4000;//五四奖学金
    if(num[i].final_exam>85&&num[i].west=='Y')num[i].money+=1000;//西部奖学金
    if(num[i].evaluation_exam>80&&num[i].class_leader=='Y')num[i].money+=850; //班级贡献奖
    }

    int sum=0;
    sort(num,num+N,cmp);
    for(int i=0;i<N;i++)
    sum+=num[i].money;

    cout<<num[N-1].name<<"\n"<<num[N-1].money<<"\n"<<sum<<endl;

    return 0;
    }

  • 0
    @ 2017-12-11 20:59:56

    结构体。。。
    #include<bits/stdc++.h>
    using namespace std;
    int n,sum=0;
    struct student{
    string name;//姓名
    int core;//期末测试平均分
    int classcore;//班级测评分
    char head;//是否为学生干部
    char west;//是否为西部
    int article;//发表论文数
    int money;//奖学金
    int number;//编号
    }s[105];
    bool cmp(struct student a,struct student b){
    return a.money>b.money||(a.money==b.money&&a.number<b.number);//千万别少了序号判断,少了90分。。。
    }
    int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>s[i].name>>s[i].core>>s[i].classcore>>s[i].head>>s[i].west>>s[i].article;
    s[i].number=i;
    if(s[i].core>80&&s[i].article>=1) s[i].money+=8000;
    if(s[i].core>85&&s[i].classcore>80) s[i].money+=4000;
    if(s[i].core>90) s[i].money+=2000;
    if(s[i].core>85&&s[i].west=='Y') s[i].money+=1000;
    if(s[i].classcore>80&&s[i].head=='Y') s[i].money+=850;
    sum+=s[i].money;
    }
    sort(s+1,s+1+n,cmp);
    cout<<s[1].name<<endl<<s[1].money<<endl<<sum<<endl;
    return 0;
    }

  • 0
    @ 2017-12-07 13:38:54

    请帮我看看哪里错了

    #include <iostream>
    #include <string>

    struct student {
    std::string name;
    int avgScore;
    int classScore;
    char isBan;
    char isWest;
    int pubSum;
    int money = 0;
    };

    int main()
    {
    int totalMoney = 0;
    int currentMaxStudent = 0;

    int stuNum;
    std::cout << "input student num: ";
    std::cin >> stuNum;
    student* students = new student[stuNum];

    for (int i = 0; i < stuNum; ++i) {
    std::cin >> students[i].name >> students[i].avgScore >> students[i].classScore
    >> students[i].isBan >> students[i].isWest >> students[i].pubSum;
    students[i].money += ((students[i].avgScore > 80) && (students[i].pubSum >= 1)) ? 8000 : 0;
    students[i].money += ((students[i].avgScore > 85) && (students[i].classScore > 80)) ? 4000 : 0;
    students[i].money += (students[i].avgScore > 90) ? 2000 : 0;
    students[i].money += ((students[i].avgScore > 85) && (students[i].isWest == 'Y')) ? 1000 : 0;
    students[i].money += ((students[i].avgScore > 80) && (students[i].isBan == 'Y')) ? 850 : 0;
    if (students[i].money > students[currentMaxStudent].money) {
    currentMaxStudent = i;
    }
    totalMoney += students[i].money;
    }

    printf("%s\n%d\n%d\n", students[currentMaxStudent].name.c_str(), students[currentMaxStudent].money, totalMoney);
    }

    我在MSVC里面跑了几个用例好像都是对的,为什么提交以后所有用例都失败了?

  • 0
    @ 2017-12-06 16:26:47

    n = raw_input()
    table = [raw_input().split() for i in range(int(n))]
    m = 0
    rname = ""
    ss = 0;
    for name, a, b, c, d, e in table:
    s = 0;
    if int(a) > 80 and int(e) >=1:
    s += 8000
    if int(a) > 85 and int(b) > 80:
    s += 4000
    if int(a) > 90:
    s += 2000
    if int(a) > 85 and d == 'Y':
    s += 1000
    if int(b) > 80 and c == 'Y':
    s += 850
    if s > m:
    m = s;
    rname = name
    ss += s
    print rname
    print m
    print ss

  • 0
    @ 2017-12-02 17:11:49

    #include <iostream>
    using namespace std;
    struct student{
    char name[50];
    char isxb;
    char isbg;
    int qm;
    int bp;
    int lw;
    };
    int main(){
    int n,k;//k标记最大值的位置
    student a[105];
    int max=0,sum=0,count=0;//所有学生获得奖学金的数量
    cin>>n;
    for(int i=0;i<n;i++){
    cin>>a[i].name>>a[i].qm>>a[i].bp>>a[i].isbg>>a[i].isxb>>a[i].lw;
    if(a[i].qm>80&&a[i].lw>=1)sum+=8000;
    if(a[i].qm>85&&a[i].bp>80)sum+=4000;
    if(a[i].qm>90)sum+=2000;
    if(a[i].qm>85&&a[i].isxb=='Y')sum+=1000;
    if(a[i].bp>80&&a[i].isbg=='Y')sum+=850;
    if(sum>max){
    max=sum;
    k=i;
    }
    count+=sum;
    sum=0;//sum要初始化否则会依次累加
    }
    cout<<a[k].name<<"\n"<<max<<"\n"<<count<<endl;
    return 0;
    }

  • 0
    @ 2017-11-23 13:51:09

    #include <stdio.h>
    #include <iostream>
    #include <string>
    using namespace std;
    int compare[105];
    struct student{
    char name[25];
    int termscore;
    int classscore;
    char area;
    char lingdao;
    int lunwen;
    }stu[105];
    void input(int n)
    {

    cin>>stu[n].name;
    cin>>stu[n].termscore;
    cin>>stu[n].classscore;
    cin>>stu[n].lingdao;
    cin>>stu[n].area;
    cin>>stu[n].lunwen;

    }

    int main(){
    int n;
    int c;
    int i;
    int zushu;
    cin>>n;
    c=n;
    int cnd;
    int mmax;
    int sum=0;
    while(n!=0)
    {
    input(n);
    n--;
    }
    for(i=1;i<=c;i++)
    {
    cnd=0;
    if(stu[i].termscore>80 && stu[i].lunwen >=1) cnd+=8000;
    if(stu[i].termscore>85 && stu[i].classscore>80 ) cnd+=4000;
    if(stu[i].termscore>90) cnd+=2000;
    if(stu[i].lingdao=='Y'&& stu[i].classscore>80) cnd+=850;
    if(stu[i].area=='Y'&& stu[i].termscore>85) cnd+=1000;
    compare[i]=cnd;
    }
    /// for(i=1;i<=c;i++)
    /// {
    /// cout<<compare[i]<<endl;
    ///}
    mmax=compare[1];
    for(i=1;i<=c;i++)
    {
    if(mmax<=compare[i])
    {
    mmax=compare[i];
    zushu=i;
    // cout<<"zushu="<<zushu<<endl;
    // cout<<"mmax="<<mmax<<endl;

    }
    sum+=compare[i];
    }

    cout<<stu[zushu].name<<endl;
    cout<<compare[zushu]<<endl;
    cout<<sum<<endl;
    return 0;
    }

  • 0
    @ 2017-11-23 13:44:04

    #include<bits/stdc++.h>
    using namespace std;
    struct node {
    string name;
    int qm,bj;
    char bgb,xb;
    int lw;
    int ans;
    int sum;
    }a[101];
    int n, tot=0;
    bool cmp(node x,node y) {
    if(x.ans==y.ans) return x.sum<y.sum;
    else return x.ans>y.ans;
    }
    int main() {
    scanf("%d",&n);
    for(int i=1; i<=n; i++) {
    cin>>a[i].name>>a[i].qm>>a[i].bj>>a[i].bgb>>a[i].xb>>a[i].lw;
    if(a[i].qm>80&&a[i].lw>=1) a[i].ans+=8000;
    if(a[i].qm>85&&a[i].bj>80) a[i].ans+=4000;
    if(a[i].qm>90) a[i].ans+=2000;
    if(a[i].xb=='Y'&&a[i].qm>85) a[i].ans+=1000;
    if(a[i].bj>80&&a[i].bgb=='Y') a[i].ans+=850;
    a[i].sum=i;
    tot+=a[i].ans;
    }
    sort(a+1,a+n+1,cmp);
    cout<<a[1].name<<endl<<a[1].ans<<endl<<tot;
    return 0;
    }

  • 0
    @ 2017-11-10 20:11:15

    为什么这个在自己电脑上是可以的提交就不通过呢?

    #include <stdio.h>

    int main()
    {
    struct menber
    {
    char name[20];
    int score;
    int classscore;
    char cadre;
    char west;
    int paper;
    int sum;
    }a[20];
    int i,times,sum,temp,all;
    all=0;
    scanf("%d",&times);
    for(i=0;i<times;i++){
    scanf("%s %d %d %C %c %d",&a[i].name,&a[i].score,&a[i].classscore,&a[i].cadre,&a[i].west,&a[i].paper);
    a[i].sum=0;}
    for(i=0;i<times;i++){
    if(a[i].score>80&&a[i].paper>=1) a[i].sum=a[i].sum+8000;
    if(a[i].score>85&&a[i].classscore>80) a[i].sum=a[i].sum+4000;
    if(a[i].score>90) a[i].sum=a[i].sum+2000;
    if(a[i].score>85&&a[i].west=='Y') a[i].sum=a[i].sum+1000;
    if(a[i].classscore>80&&a[i].cadre=='Y') a[i].sum=a[i].sum+850;
    }

    temp=0;
    for(i=0;i<times;i++){
    if(a[i].sum>a[temp].sum) temp=i;
    all=a[i].sum+all;}
    printf("%s\n%d\n%d",a[temp].name,a[temp].sum,all);

    }

  • 0
    @ 2017-11-08 13:53:16

    #include <stdio.h>
    #include <stdlib.h>
    #include<string.h>
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */

    int main(int argc, char *argv[]) {int n,e,i,b,a;char c,d;
    scanf("%d",&n);int f[n];
    int s=0;
    char c1[20];char c2[20];
    i=0;
    int max;
    while(n<=100&&n>=1){f[i]=0;
    scanf("%s %d %d %c %c %d",&c1,&a,&b,&c,&d,&e);
    if(d=='Y'&&b>80){
    f[i]=f[i]+850;
    }
    if(a<=100&&a>85&&b>80){
    f[i]=f[i]+4000;
    }
    if(e<=10&&e>0&&a>80){
    f[i]=f[i]+8000;
    }
    if(c=='Y'&&a>85&&a<=100){
    f[i]=f[i]+1000;
    }
    if(a>90&&a<=100){
    f[i]=f[i]+2000;
    }
    if(f[i]>f[i-1]||i==0){
    strcpy(c2,c1);
    max=i;
    }
    s=s+f[i];

    i++;
    n--;
    }
    printf("%s\n%d\n%d\n",c2,f[max],s);
    return 0;
    }

  • 0
    @ 2017-11-08 13:52:47

    #include <stdio.h>
    #include <stdlib.h>
    #include<string.h>
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */

    int main(int argc, char *argv[]) {int n,e,i,b,a;char c,d;
    scanf("%d",&n);int f[n];
    int s=0;
    char c1[20];char c2[20];
    i=0;
    int max;
    while(n<=100&&n>=1){f[i]=0;
    scanf("%s %d %d %c %c %d",&c1,&a,&b,&c,&d,&e);
    if(d=='Y'&&b>80){
    f[i]=f[i]+850;
    }
    if(a<=100&&a>85&&b>80){
    f[i]=f[i]+4000;
    }
    if(e<=10&&e>0&&a>80){
    f[i]=f[i]+8000;
    }
    if(c=='Y'&&a>85&&a<=100){
    f[i]=f[i]+1000;
    }
    if(a>90&&a<=100){
    f[i]=f[i]+2000;
    }
    if(f[i]>f[i-1]||i==0){
    strcpy(c2,c1);
    max=i;
    }
    s=s+f[i];

    i++;
    n--;
    }
    printf("%s\n%d\n%d\n",c2,f[max],s);
    return 0;
    }
    为什么这个不行?

  • 0
    @ 2017-11-06 19:49:03

    #include <stdio.h>
    struct student{
    char name[80],g,x;
    int q,b,l,jiang;
    }a[120],max;

    int main()
    {
    int n,i,k=0;
    char block;
    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%s %d %d %c %c %d",a[i].name,&a[i].q,&a[i].b,&a[i].g,&a[i].x,&a[i].l);
    a[i].jiang=0;
    if(a[i].q>80&&a[i].l>0)a[i].jiang+=8000;
    if(a[i].q>85&&a[i].b>80)a[i].jiang+=4000;
    if(a[i].q>90)a[i].jiang+=2000;
    if(a[i].q>85&&a[i].x=='Y')a[i].jiang+=1000;
    if(a[i].b>80&&a[i].g=='Y')a[i].jiang+=850;
    k+=a[i].jiang;
    }
    max=a[0];
    for(i=1;i<n;i++){
    if(max.jiang<a[i].jiang)max=a[i];
    }
    printf("%s\n%d\n%d",max.name,max.jiang,k);
    return 0;
    }

  • 0
    @ 2017-11-05 15:49:46

    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<cstdlib>
    using namespace std;
    struct point//结构体
    {
    int qm,py,lw,num,money;// 期末平均成绩,评议成绩,论文数,记录顺序,记录奖金数。
    char name[22];//名字
    char gb,xb;//干部,西北。
    } a[102];
    int qian(point a,point b)
    {
    if(a.money!=b.money)

    return a.money>b.money;
    else
    return a.num<b.num;
    } //按从大到小排序奖金数,并排出输入顺序。
    /*int ming(point a,point b)
    {
    return a.num<b.num;
    }*/
    int main()
    {
    int n,total=0;//n,total用于记录总钱数
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    a[i].num=i;
    scanf("%s%d%d%s%s%d",&a[i].name,&a[i].qm,&a[i].py,&a[i].gb,&a[i].xb,&a[i].lw);
    if(a[i].qm>80&&a[i].lw>=1)
    a[i].money+=8000;//院士奖学金
    if(a[i].qm>85&&a[i].py>80)
    a[i].money+=4000;//五四奖学金
    if(a[i].qm>90)
    a[i].money+=2000;//成绩优秀奖
    if(a[i].qm>85&&a[i].xb=='Y')
    a[i].money+=1000;//西部奖学金
    if(a[i].py>80&&a[i].gb=='Y')
    a[i].money+=850;//班级贡献奖
    total+=a[i].money;//总奖金数
    }

    sort(a+1,a+n+1,qian);//从小到大排序

    printf("%s\n",a[1].name);//输出
    printf("%d\n",a[1].money);
    printf("%d\n",total);
    return 0;
    }

  • 0
    @ 2017-11-02 14:16:44

    纯模拟
    cpp
    #include <iostream>
    using namespace std;
    int n,ans[110],z,_max;//学生数,每个学生的奖学金,奖学金总和,最多奖学金的学生序号
    struct student{
    char na[21];//名字
    int ts;//期末成绩
    int cs;//班级评测成绩
    char isc;//是否班干部
    char isw;//是否西部学生
    int t;//发表论文数
    }stu[110];
    int main()
    {
    cin>>n;
    for(int i=0;i<n;i++)
    {
    cin>>stu[i].na>>stu[i].ts>>stu[i].cs>>stu[i].isc>>stu[i].isw>>stu[i].t;
    if(stu[i].ts>80&&stu[i].t>=1) ans[i]+=8000;
    if(stu[i].ts>85&&stu[i].cs>80) ans[i]+=4000;
    if(stu[i].ts>90) ans[i]+=2000;
    if(stu[i].ts>85&&stu[i].isw=='Y') ans[i]+=1000;
    if(stu[i].cs>80&&stu[i].isc=='Y') ans[i]+=850;
    }
    for(int i=0;i<n;i++)
    {
    if(ans[i]>ans[_max]) _max=i;
    z+=ans[i];
    }
    cout<<stu[_max].na<<"\n"<<ans[_max]<<"\n"<<z;
    return 0;
    }

  • 0
    @ 2017-10-29 19:19:20

    #include <iostream>
    #include <cmath>
    #include <cstring>
    #include <cstdlib>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    int main()
    {
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int i,n;
    cin>>n;
    char name[10001],ganbu,west;
    int last,banji,topic;
    char name_1[10001];
    int person,c=0,max=-2147483644;
    for (i=0;i<n;i++)
    {
    cin>>name>>last>>banji>>ganbu>>west>>topic;
    person=0;
    if (last>80&&topic>=1)
    person+=8000;
    if (last>85&&banji>80)
    person+=4000;
    if (last>90)
    person+=2000;
    if (last>85&&west=='Y')
    person+=1000;
    if (banji>80&&ganbu=='Y')
    person+=850;
    if (person>max)
    {
    max=person;
    strcpy(name_1,name);
    }
    c+=person;
    }
    cout<<name_1<<endl<<max<<endl<<c<<endl;
    system("pause");
    return 0;
    }

  • 0
    @ 2017-10-29 19:18:55

    #include <iostream>
    #include <cmath>
    #include <cstring>
    #include <cstdlib>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    int main()
    {
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int i,n;
    cin>>n;
    char name[10001],ganbu,west;
    int last,banji,topic;
    char name_1[10001];
    int person,c=0,max=-2147483644;
    for (i=0;i<n;i++)
    {
    cin>>name>>last>>banji>>ganbu>>west>>topic;
    person=0;
    if (last>80&&topic>=1)
    person+=8000;
    if (last>85&&banji>80)
    person+=4000;
    if (last>90)
    person+=2000;
    if (last>85&&west=='Y')
    person+=1000;
    if (banji>80&&ganbu=='Y')
    person+=850;
    if (person>max)
    {
    max=person;
    strcpy(name_1,name);
    }
    c+=person;
    }
    cout<<name_1<<endl<<max<<endl<<c<<endl;
    system("pause");
    return 0;
    }

  • 0
    @ 2017-10-29 19:18:47

    #include <iostream>
    #include <cmath>
    #include <cstring>
    #include <cstdlib>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    int main()
    {
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int i,n;
    cin>>n;
    char name[10001],ganbu,west;
    int last,banji,topic;
    char name_1[10001];
    int person,c=0,max=-2147483644;
    for (i=0;i<n;i++)
    {
    cin>>name>>last>>banji>>ganbu>>west>>topic;
    person=0;
    if (last>80&&topic>=1)
    person+=8000;
    if (last>85&&banji>80)
    person+=4000;
    if (last>90)
    person+=2000;
    if (last>85&&west=='Y')
    person+=1000;
    if (banji>80&&ganbu=='Y')
    person+=850;
    if (person>max)
    {
    max=person;
    strcpy(name_1,name);
    }
    c+=person;
    }
    cout<<name_1<<endl<<max<<endl<<c<<endl;
    system("pause");
    return 0;
    }

  • 0
    @ 2017-10-17 12:35:07

    type
    Tnode=record
    nam:string;
    adv,cla,num,tot:longint;
    job,west:boolean;
    end;
    var
    st:string;
    N,i,p,q,ans,max:longint;
    a:array[1..100]of Tnode;
    begin
    readln(N);
    max:=0;
    for i:=1 to N do
    begin
    readln(st);
    a[i].job:=false;
    a[i].west:=false;
    p:=pos(' ',st);
    a[i].nam:=copy(st,1,p-1);
    delete(st,1,p);
    p:=pos(' ',st);
    val(copy(st,1,p-1),a[i].adv);
    delete(st,1,p);
    p:=pos(' ',st);
    val(copy(st,1,p-1),a[i].cla);
    delete(st,1,p);
    if st[1]='Y' then a[i].job:=true;
    if st[3]='Y' then a[i].west:=true;
    delete(st,1,4);
    val(st,a[i].num);
    if (a[i].adv>80)and(a[i].num>=1) then inc(a[i].tot,8000);
    if (a[i].adv>85)and(a[i].cla>80) then inc(a[i].tot,4000);
    if a[i].adv>90 then inc(a[i].tot,2000);
    if (a[i].adv>85)and(a[i].west) then inc(a[i].tot,1000);
    if (a[i].cla>80)and(a[i].job) then inc(a[i].tot,850);
    ans:=ans+a[i].tot;
    if a[i].tot>max then
    begin
    max:=a[i].tot;
    q:=i;
    end;
    end;
    writeln(a[q].nam);
    writeln(a[q].tot);
    write(ans);
    end.

  • 0
    @ 2017-09-24 21:34:25

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    int m,n,ans;
    int a[11][11],xxx[8]={1,2,1,2,-1,-2,-1,-2},yyy[8]={2,1,-2,-1,2,1,-2,-1};
    void work(int x,int y,int j)
    {
    j++;a[x][y]=1;
    if(j==m*n){ans++;}
    for(int i=0;i<8;i++)
    {
    if(x+xxx[i]>0&&x+xxx[i]<=n&&y+yyy[i]>0&&y+yyy[i]<=m&&!a[x+xxx[i]][y+yyy[i]])
    work(x+xxx[i],y+yyy[i],j);
    }
    a[x][y]=0;
    }

    int main()
    {
    int T,xx,yy;
    cin>>T;
    for(int i=1;i<=T;i++)
    {
    ans=0;
    memset(a,0,sizeof(a));
    cin>>n>>m>>xx>>yy;
    xx++;yy++;
    work(xx,yy,0);
    cout<<ans<<endl;
    //for(int i=1;i<=n;i++)
    //for(int j=1;j<=m;j++)
    //cout<<a[i][j]<<endl;
    }
    return 0;
    }

  • 0
    @ 2017-09-14 20:21:56

    #include <iostream>
    using namespace std;
    int main()
    {
    //数据输入变量声明
    int N;//数据个数
    string Name;//学生名字
    int Average;//平均成绩
    int PingYiChengJi;//评议成绩
    char IsGanBu;//是否干部
    char IsWest;//是否西部学生
    int NumLunWen;//发表的论文数量

    //数据输出变更声明
    string NameZuiDuoName;//最多奖学金的学生的名字
    int JiangJinSum = 0;//这名学生的资金总数
    int JiangJinZuiDuo = 0;//最多奖金数
    int JiangJingSum2 = 0;//所有学生的奖金之和

    //实现
    cin >> N;
    for (int i = 0; i < N; i++)
    {
    JiangJinSum = 0;
    cin >> Name >> Average >> PingYiChengJi >> IsGanBu >> IsWest >> NumLunWen;
    if (Average > 80 && NumLunWen >= 1)
    JiangJinSum += 8000;
    if (Average > 85 && PingYiChengJi > 80)
    JiangJinSum += 4000;
    if (Average > 90)
    JiangJinSum += 2000;
    if (Average > 85 && IsWest == 'Y')
    JiangJinSum += 1000;
    if (PingYiChengJi > 80 && IsGanBu == 'Y')
    JiangJinSum += 850;
    JiangJingSum2 += JiangJinSum;//所有学生的奖金之和
    if (JiangJinSum > JiangJinZuiDuo)
    {
    NameZuiDuoName = Name;//最多奖学金的学生的名字
    JiangJinZuiDuo = JiangJinSum;//最多奖金数
    }
    }
    cout << NameZuiDuoName << endl << JiangJinZuiDuo << endl << JiangJingSum2 << endl;
    cin >> N;
    }

  • 0
    @ 2017-08-22 17:06:16

    #include<stdio.h>
    #include<string.h>
    #include<iostream>
    #include<string>
    using namespace std;

    class s{
    public:
    string name;
    int qm,py;
    char gb,xb;
    int lw;
    int jxj;
    };

    s st[105];

    int f(s a)
    {
    int sum=0;
    if(a.qm>80&&a.lw>=1)sum+=8000;
    if(a.qm>85&&a.py>80)sum+=4000;
    if(a.qm>90)sum+=2000;
    if(a.qm>85&&a.xb=='Y')sum+=1000;
    if(a.py>80&&a.gb=='Y')sum+=850;
    return sum;
    }
    int main()
    {
    int N;
    int sum=0;
    cin>>N;
    for(int i=0;i<N;i++){
    // scanf("%s %d %d %c %c %d",&st[i].name,&st[i].qm,&st[i].py,&st[i].gb,&st[i].xb,&st[i].lw);
    cin>>st[i].name>>st[i].qm>>st[i].py>>st[i].gb>>st[i].xb>>st[i].lw;
    // cout<<st[i].name<<st[i].qm<<st[i].py<<st[i].gb<<st[i].xb<<st[i].lw<<endl;
    st[i].jxj=f(st[i]);
    sum+=st[i].jxj;
    }
    string n;
    n=st[0].name;int ma=st[0].jxj;
    for(int i=1;i<N;i++){
    if(st[i].jxj>ma){
    ma=st[i].jxj;
    n=st[i].name;
    }
    }
    cout<<n<<endl<<ma<<endl<<sum<<endl;
    return 0;
    }

信息

ID
1001
难度
5
分类
模拟 点击显示
标签
递交数
39260
已通过
12791
通过率
33%
被复制
130
上传者