Problem B: 农夫果园 简单点,出题的方式简单点
我走过最长的路,就是教主的套路
#include <iostream> #include <string> using namespace std; class Fruit { public: double price; double weight; double income; virtual void input(){cin>>price>>weight;} virtual double total(){return income;} }; class Apple:public Fruit { int m,n; public: void input() { double a,b; cin>>a>>b; price=a; weight=b; income=price*weight*30; } virtual double total() { return income; } }; class Banana:public Fruit { int m,n; public: virtual void input() { double a,b; cin>>a>>b; price=a; weight=b; income=price*weight*25; } virtual double total() { return income; } }; class Pear:public Fruit { int m,n; public: virtual void input() { double a,b; cin>>a>>b; price=a; weight=b; income=price*weight*20; } virtual double total() { return income; } }; 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 B: 农夫果园 简单点,出题的方式简单点的更多相关文章
- ASP.Net Core下Authorization的几种方式 - 简书
原文:ASP.Net Core下Authorization的几种方式 - 简书 ASP.Net Core下Authorization的几种方式 Authorization其目标就是验证Http请求能否 ...
- ASCII、Unicode、UTF-8、UTF-16、GBK、GB2312、ANSI等编码方式简析
ASCII.Unicode.UTF-8.UTF-16.GBK.GB2312.ANSI等编码方式简析 序言 从各种字节编码方法中,能看到那个计算机发展的洪荒时期的影子. ASCII ASCII码有标准A ...
- 单点登录技术:微软Passport单点登录协议和自由联盟规范
随着互联网络应用的普及,越来越多的人开始使用互联网上提供的服务.然而目前提供服务的网站大多采用用户名.口令的方式来识别用户身份,这使得用户需要经常性的输入自己的用户名.口令.显然这种认证方式存在着弊端 ...
- 基于IdentityServer4的OIDC实现单点登录(SSO)原理简析
写着前面 IdentityServer4的学习断断续续,兜兜转转,走了不少弯路,也花了不少时间.可能是因为没有阅读源码,也没有特别系统的学习资料,相关文章很多园子里的大佬都有涉及,有系列文章,比如: ...
- Spring多种加载Bean方式简析
1 定义bean的方式 常见的定义Bean的方式有: 通过xml的方式,例如: <bean id="dictionaryRelMap" class="java.ut ...
- oauth2.0实现sso单点登录的方式和相关代码
SSO介绍 什么是SSO 百科:SSO英文全称Single Sign On,单点登录.SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统.它包括可以将这次主要的登录映射到其他 ...
- Redis 部署方式(单点、master/slaver、sentinel、cluster) 概念与区别
转载自 https://blog.csdn.net/java_zyq/article/details/83818341 在K8S上部署Redis集群时突然遇到一个(sentinel哨兵模式)概念,感觉 ...
- 多系统实现单点登录方案:SSO 单点登录
一.什么是单点登录SSO(Single Sign-On) SSO是一种统一认证和授权机制,指访问同一服务器不同应用中的受保护资源的同一用户,只需要登录一次,即通过一个应用中的安全验证后,再访问其他应用 ...
- SSO单点登录一:cas单点登录防止登出退出后刷新后退ticket失效报500错,也有退出后直接重新登录报票根验证错误
问题1: 我登录了client2,又登录了client3,现在我把client2退出了,在client3里面我F5刷新了一下,结果页面报错: 未能够识别出目标 'ST-41-2VcnVMguCDWJX ...
随机推荐
- 接口测试——HttpClient工具的https请求、代理设置、请求头设置、获取状态码和响应头
目录 https请求 代理设置 请求头设置 获取状态码 接收响应头 https请求 https协议(Secure Hypertext Transfer Protocol) : 安全超文本传输协议, H ...
- 自测-4 Have Fun with Numbers
Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, wit ...
- windown快速安装xgboost
记录xgboost的快速安装方式,该方式适合pyhton3.5/3.6版本. 系统: win10 64bit python版本:3.6 1. 下载xgboost编译好的whl包 下载路径为:http: ...
- wmic命令
WMIC扩展WMI(Windows Management Instrumentation,Windows管理工具) ,提供了从命令行接口和批命令脚本执行系统管理的支持. 一.如何使用帮助文档: 1.w ...
- ZOJ1171
错误代码先放这 #include<cstdio> #include<cstdlib> #include<iostream> #include<cstring& ...
- jQuery Mobile 所有class选项,开发全解+完美注释
全栈工程师开发手册 (作者:栾鹏) jQuery Mobile事件全解 jQuery Mobile 所有class选项 jQuery Mobile 所有data-*选项 jQuery Mobile 所 ...
- Oracle RAC + ASM + Grid安装
(一)环境准备 主机操作系统 windows10 虚拟机平台 vmware workstation 12 虚拟机操作系统 redhat 5.5 x86(32位) :Linux.5.5.for.x86. ...
- Ubuntu配置OpenStack 一:主机环境配置以及问题总结
本文包含openstack配置的实验环境的基本步骤.在下面的步骤中将逐步讲解如何操作. 1.准备三台虚拟机 主机名字分别命名为controller.network.computer[desktop版或 ...
- linux 下的文件目录操作之遍历目录
通过递归调用读取目录和文件信息去遍历整个目录: 示例代码: #include <unistd.h> #include <stdio.h> #include <dirent ...
- OpenWRT添加模块 Makefile和Config.in
添加模块编译 在网上找了一下,很多关于编译Openwrt系统的资料,不过这些事情芯片厂商提供的开发包都已经办得妥妥了,但是没有找到系统介绍的资料,添加一个包的介绍有不多,其中有两个很有参考价值: ht ...