Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6. #include <iomanip>
  7.  
  8. #define K_TO_M 0.6214
  9. #define M_TO_K 1.6093
  10.  
  11. int main()
  12. {
  13.     double n = 1, k;
  14.  
  15.     std::cout << "Input k: ";
  16.     std::cin >> k;
  17.  
  18.     std::cout << "Mili     |  KM" << std::endl;
  19.  
  20.     if (k >= 0) {
  21.         std::cout << std::setprecision(4) << std::fixed;
  22.  
  23.         for (double i = 1; i <= ceil(k); i++)
  24.         {
  25.             if (i / 1.609344 < n) {
  26.                 printf("%.4f   %.4f\n", i / 1.609344, i);
  27.             }
  28.             else {
  29.                 if (n*1.609344 <= k) {
  30.                     printf("%.4f   %.4f\n", n, n*1.609344);
  31.                 }
  32.  
  33.                 if (i <= k) {
  34.                     printf("%.4f   %.4f\n", i / 1.609344, i);
  35.                 }
  36.  
  37.                 n++;
  38.             }
  39.         }
  40.     }
  41.     else {
  42.         std::cout << "Enter more than 0" << std::endl;
  43.     }
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement