沒有關注餘弦定律,我的代碼波紋管試圖解決給定的邊和角度。如果還有一種方法,我如何使用cin >>來檢索多個字符,如您所見,我要求用戶輸入'A'或'S'。C++正弦/餘弦計算器
Here is my code and the results
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
char solvefor;
double A; // I used doubles to have specific answers
double a;
double B;
double b;
double C;
double c;
cout << "What are you trying to solve? <ASA(A) or SSA(S)>";
cin >> solvefor;
if (solvefor == 'S')
{
cout << "What is the value of b?" << endl;
cin >> b;
cout << "What is the angle B?" << endl;
cin >> B;
cout << "What is the side c?" << endl;
cin >> c;
C = asin((sin(B)/b) * c);
cout << "Your missing C angle is " << C << endl;
A = 180 - C - B;
cout << "Your missing A angle is " << A << endl;
a = (sin(A) *b)/sin(B);
} else {
return 0; //I will work on law of cosine later
}
}
我會收到弧度而不是度的答案,任何幫助嗎?
你的問題是什麼? – UnholySheep
正弦和餘弦函數使用弧度等級 – eyllanesc
不清楚你對字符輸入的要求,現在的方式很好 –