PAT Advanced 1058 A+B in Hogwarts (20 分)
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 ;
}
PAT Advanced 1058 A+B in Hogwarts (20 分)的更多相关文章
- PAT 甲级 1058 A+B in Hogwarts (20 分) (简单题)
1058 A+B in Hogwarts (20 分) If you are a fan of Harry Potter, you would know the world of magic ha ...
- 1058 A+B in Hogwarts (20分)
1058 A+B in Hogwarts (20分) 题目: If you are a fan of Harry Potter, you would know the world of magic h ...
- PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642
PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...
- PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642
PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...
- PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642
PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...
- PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642
PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642 题目描述: A reversible prime in any n ...
- 【PAT甲级】1058 A+B in Hogwarts (20 分)
题意: 输入两组,每组三个非负整数A,B,C(A<=1e7,B<17,C<29),输出相加的和.(类似个位上29进制,十位上17进制运算) AAAAAccepted code: #d ...
- PAT (Advanced Level) Practice 1152 Google Recruitment (20 分)
In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the p ...
- PAT Advanced 1031 Hello World for U (20 分)
Given any string of N (≥) characters, you are asked to form the characters into the shape of U. For ...
随机推荐
- 解决img标签与其它标签间隙问题?
解决img标签间距问题 关于img标签间距问题:多个img之间有间距,包含img标签的div之间有间距 代码如下: <!DOCTYPE html> <html> <hea ...
- 第四周总结&实验报告二
第四周总结&实验报告二 课程总结 这周我们学习了string类,以及很多string类的很多操作方法,同时string也是一个对象,在用到它时我们首字母需要大写,这周我们还加深了对函数构造的理 ...
- 【机器学习速成宝典】模型篇04k近邻法【kNN】(Python版)
目录 什么是k近邻算法 模型的三个基本要素 构造kd树 kd树的最近邻搜索 kd树的k近邻搜索 Python代码(sklearn库) 什么是K近邻算法(k-Nearest Neighbor,kNN) ...
- linux 汇编函数调用
edi第一个参数 esi第二个参数 edx第三个参数 rax保存结果 C++代码如下: char* demo(char* a,int b){ static char* buf=0; if(!buf)b ...
- Linux_用户权限管理
目录 目录 用户管理 useradd创建用户 userdel删除用户 usermod修改用户账号 passwd修改用户密码 用户权限设置 用户组管理 查看用户的属组 修改用户组gpasswd 为没有家 ...
- 阶段3 1.Mybatis_09.Mybatis的多表操作_3 完成account的一对一操作-通过写account的子类方式查询
先把多表查询的sql语句写出来 想要显示的字段 创建一个AccountUser类 继承Account.这样它就会从父类上继承一些信息 这里只需要定义username和address就可以了 .然后生成 ...
- IDEA反编译jar包源码
1.maven 项目查看jar源码 如何在idea中查看jar包源码 文章目录 准备jar包 idea打开文件夹 最后一步 准备jar包 例如,我准备看resin的jar,在桌面准备了一份 ide ...
- ARTS-2
ARTS的初衷 Algorithm:主要是为了编程训练和学习.每周至少做一个 leetcode 的算法题(先从Easy开始,然后再Medium,最后才Hard).进行编程训练,如果不训练你看再多的算法 ...
- 合理设置redis主从buffer 不错
背景 某次抢购时,一个redis集群的某个分片,从实例响应时间陡增到几十秒,报警后运维将其中一个本应该下线的slave下掉,问题减轻但没有解决,又把另一个正常的slave下线掉,问题消失. maste ...
- 【Airtest】由于Airtest中long_click无法实现长按,教你如何在Airtest中实现长按的方法
Airtest中我们想要实现长按操作,poco中有一个方法long_click,但是实际使用了一下,发现并没有卵用,仍然是单击操作,如下图 那我们要如何进行长按操作呢?其实可以利用swipe实现,以长 ...