Page MenuHomec4science

rebonds2.cc
No OneTemporary

File Metadata

Created
Fri, May 31, 09:15

rebonds2.cc

#include <iostream>
#include <cmath>
using namespace std ;
int main()
{
cout << "Hauteur initiale H0 ?" << endl;
float H0;
cin >> H0;
if (H0 <= 0)
{
cout << "L'expérience s'effectue au-dessus du niveau de la mer." << endl;
return 0;
}
cout << "Coefficient de rebond eps ?" << endl;
float eps;
cin >> eps;
if (eps < 0 || eps >=1)
{
cout << "0 <= eps < 1" << endl;
return 0;
}
cout << "Hauteur finale désirée h_fin ?" << endl;
int h_fin;
cin >> h_fin;
if (h_fin <= 0 || h_fin >= H0)
{
cout << "0 < h_fin < H0" << endl;
return 0;
}
cout << endl;
float v, v1, h;
int i(0);
h=H0;
while (h > h_fin)
{
i=i+1;
v=sqrt(2*h*9.81);
v1=eps*v;
h=v1*v1/(2*9.81);
}
cout << "Hauteur au rebond " << i << " : " << h << endl;
return 0 ;
}

Event Timeline