好贷网好贷款

编程练习之旅 pat 1058

发布时间:2016-12-4 14:22:37 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"编程练习之旅 pat 1058",主要涉及到编程练习之旅 pat 1058方面的内容,对于编程练习之旅 pat 1058感兴趣的同学可以参考一下。

题目描述: 1058. A+B in Hogwarts (20) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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, 107], 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 <stdio.h> #include <string.h> int main() { int resg,ress,resk; int a_gall,a_sick,a_knut; int b_gall,b_sick,b_knut; scanf("%d.%d.%d %d.%d.%d",&a_gall,&a_sick, &a_knut,&b_gall,&b_sick,&b_knut); if(a_knut+b_knut > 28) { a_sick++; resk = a_knut+b_knut - 29; } else resk = a_knut+b_knut; if(a_sick + b_sick > 16) { a_gall ++; ress = a_sick + b_sick - 17; } else ress = a_sick + b_sick; resg = a_gall + b_gall; printf("%d.%d.%d\n",resg,ress,resk); return 0; }

上一篇:IOS开发中NSRunloop跟NSTimer的问题
下一篇:黑马程序员_java语言基础组成

相关文章

相关评论