1037. 在霍格沃茨找零钱(20)

来源:互联网 发布:阿里云企业邮箱设置 编辑:程序博客网 时间:2024/06/05 00:53
#include<stdio.h>int main(){  long Gallon1=0,Gallon2=0,Gallon3,temp=0;  int Sickle1=0,Sickle2=0,Knut1=0,Knut2=0,Sickle3,Knut3,flag1=0,flag2=0,flag3=0,temp1,temp2;  scanf("%ld.%d.%d",&Gallon1,&Sickle1,&Knut1);  scanf("%ld.%d.%d",&Gallon2,&Sickle2,&Knut2);  if((Gallon2*29*17+Sickle2*29+Knut2)<(Gallon1*29*17+Sickle1*29+Knut1))  {    flag3 = 1;    temp = Gallon2;    Gallon2 = Gallon1;    Gallon1 = temp;    temp1 = Sickle2;    Sickle2 = Sickle1;    Sickle1 = temp1;    temp2 = Knut2;    Knut2 = Knut1;    Knut1 = temp2;  }  Knut3 = Knut2 - Knut1;  if(Knut3<0)  {    flag1 = 1;    Knut3 += 29;  }  if(flag1)    Sickle2--;  Sickle3 = Sickle2 - Sickle1;  if(Sickle3<0)  {    flag2 = 1;    Sickle3 += 17;  }  if(flag2)    Gallon2--;  Gallon3 = Gallon2 - Gallon1;  if(flag3)    printf("-");  printf("%ld.%d.%d",Gallon3,Sickle3,Knut3);  return 0;}

0 0
原创粉丝点击