Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int arr[7] = {1,10,100,1000,10000,100000,10000000};
  5.  
  6. int main() {
  7. int cases; scanf("%d",&cases);
  8. while(cases--)
  9. {
  10. double num; string unit1,unit2;
  11. scanf("%d",&num); cin>>unit1>>unit2;
  12. int eq,eq2;
  13. if(unit1=="km") eq=0;
  14. else if(unit1=="hm") eq=1;
  15. else if(unit1=="Dm") eq=2;
  16. else if(unit1=="m") eq=3;
  17. else if(unit1=="dm") eq=4;
  18. else if(unit1=="cm") eq=5;
  19. else if(unit1=="mm") eq=6;
  20.  
  21. if(unit2=="km") eq2=0;
  22. else if(unit2=="hm") eq2=1;
  23. else if(unit2=="Dm") eq2=2;
  24. else if(unit2=="m") eq2=3;
  25. else if(unit2=="dm") eq2=4;
  26. else if(unit2=="cm") eq2=5;
  27. else if(unit2=="mm") eq2=6;
  28. double sol;
  29. if(eq>eq2) sol=num*(arr[eq]-arr[eq2]);
  30. else if(eq<eq2) sol=num/(arr[eq2]-arr[eq]);
  31.  
  32. printf("%llf\n",sol);
  33. }
  34. return 0;
  35. }
  36.  
  37. /**
  38. #include <bits/stdc++.h>
  39. using namespace std;
  40.  
  41.  
  42. int main() {
  43. cout<<"Hello World";
  44. return 0;
  45. }
  46.  
  47. #include <bits/stdc++.h>
  48. using namespace std;
  49.  
  50.  
  51. int main() {
  52. cout<<"Hello World";
  53. return 0;
  54. }
  55.  
  56. #include <bits/stdc++.h>
  57. using namespace std;
  58.  
  59.  
  60. int main() {
  61. cout<<"Hello World";
  62. return 0;
  63. }
  64.  
  65. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement