Problem E: 农夫果园
Home | Web Board | ProblemSet | Standing | Status | Statistics |
Problem E: 农夫果园
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 1338 Solved: 1085
[Submit][Status][Web Board]
Description
Input
输入的第一个整数n,表示后面有n条水果收购的记录。每条记录分为3部分,水果种类、单价和总量。
Output
输出为一行,表示整个果园卖出水果的总价。
Sample Input
Sample Output
HINT
Append Code
[Submit][Status][Web Board]
한국어< 中文 فارسی English ไทย
All Copyright Reserved 2010-2011 SDUSTOJ TEAM
GPL2.0 2003-2011 HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin:admin
#include <iostream>
using namespace std;
class Fruit
{
public:virtual void input() = 0;virtual double total() const = 0;
public:Fruit( ) { }
protected:double uprice;int num;
};
class Apple : public Fruit
{
public:void input() { cin >> uprice; cin >> num; }double total() const { return uprice * num * 30; }
public:Apple( ) : Fruit() { }
};class Banana : public Fruit
{
public:void input() { cin >> uprice; cin >> num; }double total() const { return uprice * num * 25; }
public:Banana( ) : Fruit() { }
};class Pear : public Fruit
{
public:void input() { cin >> uprice; cin >> num; }double total() const { return uprice * num * 20; }
public:Pear( ) : Fruit() { }
};int main()
{Fruit* fruit;string fruit_name;double sum = 0.0;int cases;cin >> cases;for(int i = 1; i <= cases; i++){cin >> fruit_name;if(fruit_name == "Apple")fruit = new Apple();if(fruit_name == "Banana")fruit = new Banana();if(fruit_name == "Pear")fruit = new Pear();fruit->input();sum += fruit->total();delete fruit;}cout << "Total Price : " << sum << endl;return 0;
}
Problem E: 农夫果园相关推荐
- Problem A: 农夫果园
Problem A: 农夫果园 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 2089 Solved: 1702 [Submit][Status][ ...
- 实验9:Problem C: 农夫果园
Home Web Board ProblemSet Standing Status Statistics Problem C: 农夫果园 Problem C: 农夫果园 Time Limit: 1 S ...
- Problem C: 农夫果园
Description 一果农,家里有苹果树.梨树,2016年收成不错,现在需要你来编程,求一下去年总共收获了多少斤的水果. Input 第一行N表示之后有N行输入. 之后的N行输入,每行一个水果.包 ...
- SDUSTOJ1670 Problem C: 农夫果园
Description 秋天到了,果园里的水果成熟了,商贩们来收水果了,农夫们都希望自己的水果能卖个好价钱. 现在果园里有三种水果正在销售,苹果(Apple).香蕉(Banana).梨(Pear).每 ...
- linux下yum错误:[Errno 14] problem making ssl connection Trying other mirror.
所有的base 都要取消注释 mirrorlist 加上注释 另外所有的enable都要设为零 目录 今天是要yum命令安装EPEL仓库后 yum install epel-release 突然发现y ...
- A + B Problem
1001: A + B Problem Description 计算 A + B. Input 多组测试数据,每组测试数据占一行,包括2个整数. Output 在一行中输出结果. Sample Inp ...
- Error:(49, 1) A problem occurred evaluating project ':guideview'. Could not read script 'https://r
出现问题如下: Error:(49, 1) A problem occurred evaluating project ':guideview'. > Could not read script ...
- #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)
题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...
- ADPRL - 近似动态规划和强化学习 - Note 3 - Stochastic Infinite Horizon Problem
Stochastic Infinite Horizon Problem 3.Stochastic Infinite Horizon Problem 定义3.1 无限范围的马尔可夫决策过程 (Marko ...
最新文章
- 智能算法把奥巴马识别成白人,AI也学会歧视了?
- 微信小程序 获取用户信息 官网例程 详解
- 视频 + PPT | 数字化运营,从理论到实践
- bootstrap加载mysql数据库_bootstrap后台管理系统前后台实现(含数据库)
- python3.6串口编程实例_使用python3实现操作串口详解
- [转] left join/right join/inner join操作演示
- 微课|中学生可以这样学Python(2.2.3节):in和is
- 大数据的核心价值表现在哪里
- 产品经理的工作感想(2)
- Spring IOC的三种主要注入方式?
- viper4android 机顶盒,利用VIPer53封装上系统实现经济型机顶盒供电
- 分页组件extremeComponents的使用
- 西门子200PLC指令详解——位逻辑指令
- 计算机网络-名词解释整理
- pthread_attr_setinheritsched,pthread_attr_setschedparam函数详解
- 通过温度湿度计算露点
- android wear iphone7,多款Android Wear手表不兼容苹果iPhone7
- 电脑白屏,电脑白屏是怎么回事?是系统的原因还是
- 坐地铁,玩Android
- 避雷:六种职场着装可能导致你面试失败
热门文章
- 接口测试工具(下篇)——命令行工具curl
- 阿里刘振飞:我们用了10年,从去IOE到OceanBase世界第一!
- EOJ 3452- 唐纳德先生和假骰子
- 【Debias】Model-Agnostic Counterfactual Reasoning for Eliminating Popularity Bias in RS(KDD‘21)
- 明源云童继龙:围绕地产生态链,做好数字化转型加速器
- 《MATLAB语音信号分析与合成(第二版)》:第10章 语音信号的合成算法
- 什么事DDoS?什么事ADS?看ADS如何治愈DDoS伤痛
- 互联网行业常见数据分类:用户数据、行为数据、业务数据
- Oracle 300问
- 用户注册邮箱通知和短信通知详解(php)