PAT Advanced 1058 A+B in Hogwarts (20 分)
2024-09-05 20:06:01
If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it's easy enough." Your job is to write a program to compute A+B where A and B are given in the standard form of Galleon.Sickle.Knut
(Galleon
is an integer in [0], Sickle
is an integer in [0, 17), and Knut
is an integer in [0, 29)).
Input Specification:
Each input file contains one test case which occupies a line with A and B in the standard form, separated by one space.
Output Specification:
For each test case you should output the sum of A and B in one line, with the same format as the input.
Sample Input:
3.2.1 10.16.27
Sample Output:
14.1.28
#include<iostream>
using namespace std;
struct money{
int g;
int s;
int k;
};
int main() {
money a,b,res;
scanf("%d.%d.%d %d.%d.%d",&a.g,&a.s,&a.k,&b.g,&b.s,&b.k);
res.g=a.g+b.g;
res.s=a.s+b.s;
res.k=a.k+b.k;
if(res.k>){
res.k-=;
res.s++;
}
if(res.s>){
res.s-=;
res.g++;
}
cout<<res.g<<"."<<res.s<<"."<<res.k;
system("pause");
return ;
}
最新文章
- [LeetCode] Remove K Digits 去掉K位数字
- Mysql两个引擎对比
- Python 爬虫5——爬取并下载网页指定规格的图片
- Windows 7您的凭据不工作
- dnspod动态域名使用感受
- js对select动态添加和删除OPTION
- lib制作
- DevExpress gridView 小结(一)
- Flume学习——Flume中事务的定义
- Android: 在WebView中获取网页源码
- Ext JS学习第十二天 Ext基础之操作dom ; get与fly 方法
- thinkphp系列:类的自动加载是如何设计的
- Flask学习 一 基本结构
- iOS masonry 不规则tagView布局 并自适应高度
- 2018-2019-2 20165328《网络对抗技术》Exp0 Kali安装week1
- react 自我小计
- Ubuntu 14.04 + gnome session back (metacity) 任务栏右上角图标消失问题解决
- cocos2d-js 3.0 rc2 自定义UI控件组件 例子:能播放动画的MenuItem。MenuItemSprite的bug
- 13 jmeter性能测试实战--FTP程序
- ExtJS模版技术
热门文章
- 错误1919,配置ODBC数据源MS Access Database时发生错误ODEC错误
- 数据库MySQL(课下作业,必做) 20175225
- C# 读取Excel中的数据到DataTable中
- 【零售App】—— react/ant design mobile项目爬坑
- lnmp源码搭建
- 怎么用jira写bug
- hashMap与 hashTable , ArrayList与linkedList 的区别(详细)
- 【MyBatis】-----【MyBatis】---表级联系【一对一】--增删改查
- Matlab——图形绘制——三维立体图形 剔透玲珑球 动态图——彗星状轨迹图
- Django 优秀资源大全