A.运动会

A.运动会
Time Limit: 1000 MSMemory Limit: 32768 K
Total Submit: 97 (69 users)Total Accepted: 71 (69 users)Special Judge: No
Description
利用面向对象设计方法解决问题。
    运动会结束后统计各学院运动员绩点分数。
    现有类College的完整定义,其中places表示学院团体总分排名(int型),Collegename表示学院名称(string型)。
    现完成程序计算某学院某运动员绩点分数,运动员Athlete(每人设定只参加一项比赛)信息包括:本学院团体总分排名(int型),Collegename表示学院名称(string型),name表示运动员姓名(string型),rank表示运动员个人参赛排名(int型)。
    绩点分数设定:绩点总分=成绩分+参赛分。
                  成绩分=学院团体排名前8名的每名运动员得分(9-places)*4+个人比赛排名前8的得分(9-rank)*2。团体和个人未进入前8的不得分。
                  参赛分=5。

Input
有1组测试数据。有一行输入运动员的学院团体排名,运动员个人参赛排名,学院名称,个人姓名,数据之间以空格分隔。

Output
针对输入数据,有一行输出。
    输出的内容分别是运动员所在学院名称,个人姓名,绩点总分。数据之间以空格分隔。

Sample Input
3 9 EB JACK
Sample Output
EB JACK 29
Hint
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<iomanip>
#include<cstdio>


class College{
  protected:
   int places;
   string Collegename;
  public:
   int  getP(){return places;}
   string getCN(){return Collegename;}
   void setP(int p){places=p;}
   void setCN(string n){Collegename=n;}
};
int main()
{
  Athlete a;
  int p,r;
  string cn,n;
  cin>>p>>r>>cn>>n;
  a.setALL(p,r,cn,n);
  cout<<a.getCN()<<" "<<a.getN()<<" "<<a.getTotal()<<endl;
  return 0;
}

#include<iostream>
#include<stdio.h>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdio>

using namespace std;

class College 
{
protected:
    int places;
    string Collegename;
public:
    int getP() { return places; }
    string getCN() { return Collegename; }
    void setP(int p) { places = p; }
    void setCN(string n) { Collegename = n; }
};

class Athlete
{
public:
    int places;                   //本学院团体总分排名
    string Collegename;
    string name;
    int rank;
    void setALL(int p, int r, string cn, string n)
    {
        places = p, rank = r, Collegename = cn, name = n;
    }
    string getCN()
    {
        return Collegename;
    }
    string getN()
    {
        return name;
    }
    int getTotal()
    {
        if (places < 9 && rank < 9)
        {
            return (9 - places) * 4 + (9 - rank) * 2 + 5;
        }
        else if (places < 9 && rank >= 9)
        {
            return (9 - places) * 4 + 5;
        }
        else if (places >= 9 && rank < 9)
        {
            return (9 - rank) * 2 + 5;
        }
        else return 5;
    }
};

int main()
{
    Athlete a;
    int p, r;
    string cn, n;
    cin >> p >> r >> cn >> n;
    a.setALL(p, r, cn, n);
    cout << a.getCN() << " " << a.getN() << " " << a.getTotal() << endl;
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值