#include <iostream>;
using namespace std;
/* this one works out when the float of the pi & area are in the end, but when it's in the top it does not work? */
int main()
{
float a, b;
/* float pi = 3.14 ;
float area = (pi*b*b/4) * ((2*a-b) / (2*a b)); if it's in here it doesn't work */
cout << "please inter number \n";
cin >> a ;
cout << "please inter number \n";
cin >> b ;
cout << "****\n" ;
float pi = 3.14 ;
float area = (pi*b*b/4) * ((2*a-b) / (2*a b));
cout << area << endl;
return 0;
}
uj5u.com熱心網友回復:
該區域的設定取決于運算式中使用的變數中當前的值。
使用頂部的運算式,既a沒有也b沒有設定為您的輸入值。相反,它們將具有一些任意值,這意味著您的區域也將具有一些任意值。使用and輸入后的運算式,這些值將是您輸入的實際值。ab
如果在計算之后立即放置以下代碼(在兩種情況下),您可以更清楚地看到這一點:
std::cout << "DEBUG: a = " << a << ", b = " << b
<< ", pi = " << pi << ", area = " << area << '\n';
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/512742.html
標籤:C 数学
