不知道三角函数部分该如何来写 麻烦大神给予指导
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float a, b, result;
char operation;
cout << "请输入算式,如1+2并回车:" << endl;
cin >> a >> operation >> b;
switch (operation)
{
case'+':
result = a + b;
break;
case'-':
result = a - b;
case'*':
result = a*b;
break;
case'/':
result = a / b;
break;
case'^':
result = pow(a,b);
break;
}
cout << "结果为:" << endl;
cout << a << operation << b << "=" << result << endl;
cin.get();
cin.get();
return 0;
}
switch缺å°defaultè¯å¥ï¼
ä¸è§å½æ°åååè¿ç®æä½æ¯ä¸æ ·çï¼
å¯ä»¥ä¸ç¨getå½æ°ï¼å¦æç¨getå½æ°ï¼é£å°±å®ä¹getï¼doubleï¼doubleï¼
cin >> a >> operation >> b;
switch (operation)
{
case'sin':
return = sinï¼aï¼+sinï¼bï¼ï¼
break;
case'cos':
return = cosï¼aï¼+cosï¼bï¼ï¼case'*':
result = a*b;
break;
case'tan':
result = tanï¼aï¼+tanï¼bï¼;
break;
defaultï¼ããããããã
è¶ è¿äºæ大åæ° ææªå¾ä½ 麻ç¦ä½ 帮æççå§
为ä»ä¹æ¥éäºåããããããããã
aï¼b为å±é¨åéï¼è¦å å®ä¹ædoubleå
追é®å¦ä½å®ä¹ æ¹åªé è½è¯¦ç»è¯´ä¸å ææå¦ä¸¤ä¸ªç¤¼æ å¾å¤è¯æ±ççä¸å¤ªæ
追çå¯ä»¥å°aï¼bï¼resultå®ä¹ä¸ºå ¨å±åéï¼ä¹å¯ä»¥å¨mathéé¢å®ä¹
追é®è½ä»¥ä»£ç å½¢å¼ååç»æççåããããè¿æ ·è¯´æä¸ç¥é该æä¹å¼ æççå¾è 对ä¸èµ·å¤§å¤§