首页 > 代码库 > PAT1058 A+B in Hogwarts

PAT1058 A+B in Hogwarts

 题目:PAT1058

 

题解:模拟加法和注意进位就行

 

代码:

 1 #include<cstdio>
 2 
 3 using namespace std;
 4 
 5 int a1,b1,c1,a2,b2,c2;
 6 
 7 int main()
 8 {
 9     scanf("%d.%d.%d %d.%d.%d",&a1,&b1,&c1,&a2,&b2,&c2);
10 
11     c1+=c2;
12 
13     b1+=b2;
14     b1+=(c1/29);
15 
16     c1%=29;
17 
18     a1+=a2;
19     a1+=(b1/17);
20 
21     b1%=17;
22 
23     printf("%d.%d.%d",a1,b1,c1);
24 
25     return 0;
26 
27 }

 

PAT1058 A+B in Hogwarts