疑惑
当带的钱不足时不应该三个数都是负数吗,为什么只带了一个负号。
实现(AC)
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char** argv) {
int shouldG,shouldS,shouldK;
int giveG,giveS,giveK;
scanf("%d.%d.%d %d.%d.%d",&shouldG,&shouldS,&shouldK,&giveG,&giveS,&giveK);
int shouldAll=shouldG*17*29+shouldS*29+shouldK;
int giveAll=giveG*17*29+giveS*29+giveK;
int cha=giveAll-shouldAll;
int getG=cha/(17*29);
int getSK=cha%(17*29);
int getS=getSK/29;
int getK=getSK%29;
if(getG>0)
printf("%d.%d.%d",getG,getS,getK);
else
printf("%d.%d.%d",getG,abs(getS),abs(getK));
return 0;
}