Problem A: 让动物们叫起来吧!

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 2405   Solved: 1955
[ Submit][ Status][ Web Board]

Description

Tom家里养了很多动物,比如有鸭子、火鸡和公鸡。它们的叫声都不相同。现在,请编写类Animal、Cock、Turkey和Duck,根据给出的main()函数及样例分析每个类的属性、行为及相互关系,以模仿Tom家的情况。

提示:动物们都有自己的名字。

Input

输入有多行。第一行正整数M表示之后有M个测试用例,每个测试用例包括2部分:前一部分是动物的名字,后一部分是动物的类型(用A、B、C分别表示鸭子、火鸡和公鸡)。

Output

输出有M行,每个测试用例对应一样。见样例。

Sample Input

3Baby CRubby BTobby A

Sample Output

Baby is a cock, and it can crow.Rubby is a turkey, and it can gobble.Tobby is a duck, and it can quack.

HINT

Append Code

append.cc,

[ Submit][ Status][ Web Board]

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<iostream>
using namespace std;
class Animal
{
public :
     Animal(){}
     virtual void sound(){}
};
class Cock: public Animal
{
public :
     string name;
     Cock(string n):name(n){}
     void sound(){cout<<name<< " is a cock, and it can crow." <<endl;}
};
class Turkey: public Animal
{
public :
     string name;
     Turkey(string n):name(n){}
     void sound(){cout<<name<< " is a turkey, and it can gobble." <<endl;}
};
class Duck: public Animal
{
public :
     string name;
     Duck(string n):name(n){}
     void sound(){cout<<name<< " is a duck, and it can quack." <<endl;}
};
int main()
{
     int cases;
     string name;
     char type;
     Animal *animal;
     cin>>cases;
     for ( int i = 0; i < cases; i++)
     {
        cin>>name>>type;
        switch (type)
        {
         case 'A' :
             animal = new Duck(name);
             break ;
         case 'B' :
             animal = new Turkey(name);
             break ;
         case 'C' :
             animal = new Cock(name);
             break ;
        }
        animal->sound();
     }
     return 0;
}

Problem A: 让动物们叫起来吧!相关推荐

  1. ACCV2020国际细粒度网络图像识别亚军方案总结

    大赛官网:https://www.cvmart.net/race/9917/base 背景介绍 ACCV大会(Asian Conference on Computer Vision)是由亚洲计算机视觉 ...

  2. 乌鸦可能是灵长类动物以外最聪明的动物

    corvids 这是 BBC FUTURE 上的一篇挺有意思的英文文章,把它翻译了一下(部分内容有增删),分享给大家. 今天这个主角乌鸦的名字叫贝蒂.她正走向明星之路.一群牛津大学的科学家惊奇地看着她 ...

  3. 脉冲多普勒雷达_是人类还是动物? 多普勒脉冲雷达和神经网络的目标分类

    脉冲多普勒雷达 by Braden Riggs and George Williams (gwilliams@gsitechnology.com) Braden Riggs和George Willia ...

  4. matlab兔子繁殖问题,斐波那契数列在《疯狂动物城》兔子繁衍中的应用

    摘    要: 计算思维的构建有助于帮助学生将实际问题转换为透明易懂的框架算法, 并借助计算机解决.以电影<疯狂动物城>中的兔子繁殖问题为例, 引出斐波那契数列, 引导学生将数学表达式转化 ...

  5. 四级英语作文:拯救动物

    拯救动物(Saving animals) There is an undeniable fact that the number of animals is declining faster than ...

  6. 全新版大学英语综合教程第一册学习笔记(原文及全文翻译)——6 - What Animals Really Think(动物到底想些什么)

    Unit 6 - What Animals Really Think(动物到底想些什么) Food, warmth, sleep? Their thoughts may be much deeper ...

  7. Protein Ising Model Problem

    Protein Ising Model Problem 1.预备知识 蛋白质都是由20种不同的L型α氨基酸连接形成的多聚体,在形成蛋白质后,这些氨基酸又被称为残基. 蛋白质的分子结构可划分为四级,以描 ...

  8. Problem : 狼和羊

    Problem B: 狼和羊 Description Output Sample Input Sample Output 题解 Description 米基家的后院养着一群羊,米基由于疲劳睡着了,这时 ...

  9. 一个笼子里面关了鸡和兔子(鸡有2 只脚,兔子有4 只脚,没有任何例外)。已经知道了笼子里面脚的总数a,问笼子里面至少有多少只动物,至多有多少只动物。

    Problem Description 一个笼子里面关了鸡和兔子(鸡有2 只脚,兔子有4 只脚,没有任何例外).已经知道了笼子里面脚的总数a,问笼子里面至少有多少只动物,至多有多少只动物. Input ...

最新文章

  1. vue cli3.0 引入eslint 结合vscode使用
  2. Log4j每天、每小时、每分钟定时生成日志文件
  3. Windows 服务全攻略(1)
  4. Python排序函数用法
  5. spring cloud+dotnet core搭建微服务架构:配置中心(四)
  6. scrapy框架异常--no more duplicates will be shown (see DUPEFILTER_DEBUG to show all duplicates)
  7. nodejs创建http服务器
  8. 15个常用的javaScript正则表达式
  9. PHP如何启动scrapy,php教程博客
  10. 分子动力学模拟学习2-Gromacs运行分子动力学模拟
  11. 案例| 公司信息化建设规划方案
  12. 弘辽科技:淘宝改SKU图片会影响权重吗?
  13. FTP命令 上传下载文件
  14. 获取GeoScene Pro 90天免费试用版
  15. 实验室设计规范与标准
  16. 【Java】认识Sring、String的常见操作和StringBuffer 和StringBuilder的区别【字符串详解】
  17. 关于计算机英语演讲ppt模板,英语演讲ppt模板(英语演讲8分钟ppt模板) 最新免费版...
  18. 【DB笔试面试622】在Oracle中,说说COUNT(*)计算行数有哪些优化手段?
  19. libusb系列-007-Qt下使用libusb1.0.26源码
  20. 【解决方案】EasyCVR视频结构化平台如何搭建肉品屠宰场全市联网远程监控系统?

热门文章

  1. 重庆计算机就业现状,重庆大学生就业情况统计分析.doc
  2. Hexo 建设博客部署GitHub站点
  3. 大学计算机领域论文,计算机科学技术的应用领域简述论文.doc
  4. 凝思操作系统ip配置文件interfaces与实际IP不符
  5. php布尔运算,运算符布尔运算
  6. 开源多云技术平台——Choerodon猪齿鱼发布0.19版本
  7. PDF免费在线转换网站分享
  8. dubbo 协议层【Protocol】分析
  9. 2021年《美国数学建模竞赛》攻略:注意事项与快速准备
  10. GBase项目管理实践总结-里程碑管理