Advertisement
Guest User

17a

a guest
Jan 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     float h, k;
  10.     cout << "Esercizio 17a pagina 69" << endl << "(C) Cristian Livella 2018" << endl << endl;
  11.     cout << "Inserisci l'altezza iniziale dell'onda   h = ";
  12.     cin >> h;
  13.     cout << "Inserisci i chilometri percorsi          k = ";
  14.     cin >> k;
  15.     k = floor(k);
  16.     for (int i=0; i<k; i++) {
  17.         if (h>1) {
  18.             h = h/2;
  19.         }
  20.         else {
  21.             h = 0;
  22.             break;
  23.         }
  24.     }
  25.     cout << endl << endl << "L'altezza raggiunta dall'onda dopo aver percorso " << k << " chilometri \212 di " << h << " metri" << endl << endl;
  26.     system("PAUSE");
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement