fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip> // untuk setprecision
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. int s; // sudut (0 - 90 derajat)
  9. int v; // kecepatan awal
  10. const double g = 10.0;
  11.  
  12. cin >> s;
  13. cin >> v;
  14.  
  15. // ubah sudut ke radian
  16. double s_radian = s * M_PI / 180.0;
  17.  
  18. // hitung jarak horizontal
  19. double R = (v * v * sin(2 * s_radian)) / g;
  20.  
  21. // tampilkan hasil dengan 1 angka di belakang koma
  22. cout << fixed << setprecision(1) << R << endl;
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 5324KB
stdin
37
10
stdout
9.6