我一直在遇到一些問題,直到我改變我的重力公式。現在都在工作。感謝大家。我感謝所有偉大的反饋工作中的錯誤構建C++程序來確定範圍
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
// Initialize objects:
double angle = 0.0;
double velocity = 0.0;
double range = 0.0;
const double PI = 3.141592653589793238;
const double gravity = 9.8; //meters pers second
// Input:
cout << "takeoff angle: ";
cin >> angle;
cout << "Please enter velocity: ";
cin >> velocity;
// Process
angle = angle * PI/180;
range = sin(2 * angle) * velocity * velocity/gravity;
cout << " range " << range << endl;
system("pause");
return 0;
}
這可能就是即時得到結果上面列出的,是吧?我正在努力解決它.. –