解法一:字符串处理
#include <bits/stdc++.h>using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(0); string str1, str2; cin >> str1 >> str2; int A[3], B[3]; int tmp = 0; int index = 0; for (auto &it:str1) { if (it == '.') { A[index++] = tmp; tmp = 0; } else { tmp = tmp * 10 + it - 48; } } A[2] = tmp; index = 0; tmp = 0; for (auto &it:str2) { if (it == '.') { B[index++] = tmp; tmp = 0; } else { tmp = tmp * 10 + it - 48; } } B[2] = tmp; int c; A[2] += B[2]; c = A[2] / 29; A[2] %= 29; A[1] += B[1] + c; c = A[1] / 17; A[1] %= 17; A[0] += B[0] + c; cout << A[0] << "." << A[1] << "." << A[2] << "\n";}