把单位统一了做减法。
#include <bits/stdc++.h>
using namespace std;
int c1,c2,c3;
int a1,a2,a3;
int main(){
scanf("%d.%d.%d",&c1,&c2,&c3);//应该支付
scanf("%d.%d.%d",&a1,&a2,&a3);//实际支付
//转化成统一单位
int shiji = a1*17*29+a2*29+a3;
int yinggai = c1*17*29+c2*29+c3;
if(yinggai>shiji){
swap(yinggai,shiji);
cout << "-";
}
//进行计算
int a[3];
int res = shiji-yinggai;
a[2] = res%29;
res = res / 29;
a[1] = res%17;
a[0] = res / 17;
for(int i=0;i<3;i++){
if(i<2){
cout << a[i] << ".";
}else{
cout << a[i];
}
}
return 0;
}
标签:shiji,沃茨,int,.%,29,a1,yinggai,霍格,1037
From: https://www.cnblogs.com/chengyiyuki/p/18141661