bobo_bobkata

Untitled

Jun 19th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     double num;
  6.     cin >> num;
  7.     string from, to;
  8.     cin >> from >> to;
  9.     cout.setf(ios::fixed);
  10.     cout.precision(3);
  11.     if (from == "mm") {
  12.         if (to == "m") {
  13.             cout << num / 1000 << endl;
  14.         }
  15.         else if (to == "cm") {
  16.             cout << num / 10 << endl;
  17.         }
  18.     }
  19.     else if (from == "m") {
  20.         if (to == "mm") {
  21.             cout << num * 1000 << endl;
  22.         }
  23.         else if (to == "cm") {
  24.             cout << num * 100 << endl;
  25.         }
  26.     }
  27.     else if (from == "cm") {
  28.         if (to == "mm") {
  29.             cout << num * 10 << endl;
  30.  
  31.         }
  32.         else if (to == "m") {
  33.             cout << num / 100 << endl;
  34.         }
  35.     }
  36.     return 0;
  37. }
Add Comment
Please, Sign In to add comment