牛客网PAT练兵场-在霍格沃茨找零钱
题目地址:https://www.nowcoder.com/pat/6/problem/4063
题意:按照题目的进制计算即可
1 /** 2 * 3 *作者:Ycute 4 *时间:2019-11-14-21.45.44 5 *题目题意简单描述:按照题目给定的进制计算即可 6 */ 7 8 9 #include<iostream> 10 #include<cmath> 11 #include<cstring> 12 #include<algorithm> 13 #include<vector> 14 using namespace std; 15 16 void f(int a,int b,int c,int a1,int b1,int c1){ 17 int g2,s2,k2; 18 if(c>=c1){ 19 k2=c-c1; 20 }else{ 21 b--; 22 k2=29+(c-c1); 23 } 24 if(b>=b1){ 25 s2=b-b1; 26 }else{ 27 a--; 28 s2=17+(b-b1); 29 } 30 g2=a-a1; 31 printf("%d.%d.%d\n",g2,s2,k2); 32 } 33 34 int main(){ 35 int g,s,k,g1,s1,k1; 36 scanf("%d.%d.%d",&g,&s,&k); 37 scanf("%d.%d.%d",&g1,&s1,&k1); 38 if(g>g1){ 39 printf("-"); 40 f(g,s,k,g1,s1,k1); 41 }else if(g==g1){ 42 if(s>s1){ 43 printf("-"); 44 f(g,s,k,g1,s1,k1); 45 }else if(s==s1){ 46 if(k>k1){ 47 printf("-"); 48 f(g,s,k,g1,s1,k1); 49 }else if(k==k1){ 50 printf("0.0.0"); 51 }else{ 52 f(g1,s1,k1,g,s,k); 53 } 54 }else{ 55 f(g1,s1,k1,g,s,k); 56 } 57 }else{ 58 f(g1,s1,k1,g,s,k); 59 } 60 return 0; 61 }