Description

一果农,家里有苹果树、梨树,2016年收成不错,现在需要你来编程,求一下去年总共收获了多少斤的水果。

Input

第一行N表示之后有N行输入。

之后的N行输入,每行一个水果。包括一个字符和一个整数。

其中字符是‘a’或‘p’,分别表示是一个苹果或梨。整数是这个水果的重量。

Output

见样例。

Sample Input

5a 10p 20a 30p 40a 50

Sample Output

The 1th fruit is created.The 1th apple is created.The 2th fruit is created.The 1th peach is created.The 3th fruit is created.The 2th apple is created.The 4th fruit is created.The 2th peach is created.The 5th fruit is created.The 3th apple is created.There are 5 fruits, including 3 apples and 2 peaches. Their total weights is 150.

HINT

请使用C++的面向对象来实现,练习下如何编写类、使用类。

Append Code

#include <iostream>
using namespace std;class sellFruit
{
private:static int numOfFruits, numOfApples,numOfPeach,numOfAll;
public:sellFruit(){}void setFruit(char f,int h){if(f == 'a'){numOfApples++;numOfFruits++;cout << "The "<<numOfFruits<<"th fruit is created."<< endl;cout << "The "<<numOfApples<<"th apple is created." << endl;}else{numOfFruits++;numOfPeach++;cout << "The "<<numOfFruits<<"th fruit is created."<< endl;cout << "The "<<numOfPeach<<"th peach is created." << endl;}numOfAll += h;}static void getAll(){cout << "There are "<<numOfFruits<<" fruits, including "<<numOfApples<<" apples and "<<numOfPeach<<" peaches. Their total weights is "<<numOfAll<<".";}
};
int sellFruit::numOfAll = 0;
int sellFruit::numOfPeach = 0;
int sellFruit::numOfFruits = 0;
int sellFruit::numOfApples= 0;
int main()
{int num,h;char c;sellFruit *s;cin >> num;s = new sellFruit[num];for(int i = 0;i < num;i++){cin >> c >> h;s[i].setFruit(c,h);}sellFruit::getAll();return 0;
}

Problem C: 农夫果园相关推荐

  1. Problem A: 农夫果园

    Problem A: 农夫果园 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 2089  Solved: 1702 [Submit][Status][ ...

  2. Problem E: 农夫果园

    Home Web Board ProblemSet Standing Status Statistics Problem E: 农夫果园 Time Limit: 1 Sec  Memory Limit ...

  3. 实验9:Problem C: 农夫果园

    Home Web Board ProblemSet Standing Status Statistics Problem C: 农夫果园 Problem C: 农夫果园 Time Limit: 1 S ...

  4. SDUSTOJ1670 Problem C: 农夫果园

    Description 秋天到了,果园里的水果成熟了,商贩们来收水果了,农夫们都希望自己的水果能卖个好价钱. 现在果园里有三种水果正在销售,苹果(Apple).香蕉(Banana).梨(Pear).每 ...

  5. linux下yum错误:[Errno 14] problem making ssl connection Trying other mirror.

    所有的base 都要取消注释 mirrorlist 加上注释 另外所有的enable都要设为零 目录 今天是要yum命令安装EPEL仓库后 yum install epel-release 突然发现y ...

  6. A + B Problem

    1001: A + B Problem Description 计算 A + B. Input 多组测试数据,每组测试数据占一行,包括2个整数. Output 在一行中输出结果. Sample Inp ...

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

  8. #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)

    题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...

  9. ADPRL - 近似动态规划和强化学习 - Note 3 - Stochastic Infinite Horizon Problem

    Stochastic Infinite Horizon Problem 3.Stochastic Infinite Horizon Problem 定义3.1 无限范围的马尔可夫决策过程 (Marko ...

最新文章

  1. hdu-4825(01字典树)
  2. VUE:解决 [Vue warn]: Error in render: “TypeError: item.slice is not a function“ (取部分数据)
  3. 【kafka】kafka BindException: Address already in use 一个失误或者愚蠢的问题
  4. SQL Server商业智能中ODS表和Dim表必须有的字段
  5. C#:获取访问端口号
  6. centos7安装tomcat9过程
  7. oracle集群如何搭建,Oracle集群搭建步骤.docx
  8. 我所钟爱的电影之一-文艺片
  9. 安装Pillow指定版本出错
  10. CutefishOS 0.6 Beta 发布
  11. uniny 物体运动到一个点停止_unity控制运动
  12. DNS资源纪录(Resource Record)介绍
  13. 你在工作中遇到过印象深刻的困难是什么,你怎么克服的?
  14. 如何跳过htpps安全连接(webservice/get/post)
  15. 1小时,不会代码的我如何完成 网易云音乐 大作业网页制作?(IVX 第2篇)
  16. vue给div绑定keyup的enter事件实现接电话(结合阿里云软电话SDK)
  17. 程序开发团队之团队精神篇(转)
  18. 网络安全运维工程师数据库的核心能力有什么?
  19. android系统提供的常用命令行工具
  20. Mina MEID Activator 2.120210512更新使用说明支持三网(移动、联通、电信)国行版手机解锁打电话4G苹果手机激活锁停用Hello密码锁绕ID屏幕锁密码

热门文章

  1. 《科技服务与价值链》总结
  2. php 今年 就业,深度解析PHP就业形势
  3. 从键盘输入一个4x4整数矩阵,以主对角线为对称轴,将右上角元素中较大元素代替左下角对应元素,并将左下角元素
  4. 关于召开“CIE2019第三届中国IT教育论坛”的通知
  5. 给自己一个整洁的办公环境,我是指你的电脑系统
  6. 机器人开发--Universal Scene Description(USD)
  7. 解决一个国际化标准库的问题
  8. SAP MIGO批次特性增强
  9. 什么事DDoS?什么事ADS?看ADS如何治愈DDoS伤痛
  10. pycharm调试时出现十分缓慢,变量数据没法预览的解决方法