这个题目是常见的不同进制的加法计算,处理好数据的截取和进位就好。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <string>
#include <vector>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <set>
using namespace std;
string A,B;
struct Node{
int g,s,k;
Node(){g=0;s=0;k=0;};
};
Node NA,NB;
void Convert(string s,Node & n){
int j = 0;
for(int i = 0; i < 3 ;i++){
int t_value = 0;
while(j <= (s.size()-1) && s[j] != '.'){
t_value *= 10;
t_value += s[j]-'0';
j++;
}
j++;
switch(i){
case 0:n.g = t_value;break;
case 1:n.s = t_value;break;
case 2:n.k = t_value;break;
}
}
}
void Add(Node n1,Node n2){
Node ans;
int c;
ans.k = n1.k + n2.k ;
c = ans.k /29;
ans.k %= 29;
ans.s = c + n1.s + n2.s;
c = ans.s / 17;
ans.s %= 17;
ans.g = c + n1.g + n2.g;
printf("%d.%d.%d\n",ans.g,ans.s,ans.k);
}
int main(){
cin >> A >> B;
Convert(A,NA);
Convert(B,NB);
Add(NA,NB);
return 0;
}