嘿傢伙想知道你是否可以幫助我下面的這段代碼。我的程序正在輸出一些奇怪的計算結果。C++算術運算符錯誤
#include <iostream>
using namespace std;
int main()
{
int radius;
const double PI = 3.14159265;
float area;
float circumference;
cout << "Program to find the area and circumference of a circle\n\n\n";
cout << "Please enter the radius: ";
radius = cin.get();
area = PI * (radius * radius);
circumference = (2 * radius) * PI;
cout << "The area of your circle is " << area << ", the circumference of your circle is " << circumference <<"\n\n";
system("PAUSE");
}
對於某些示例輸入,您希望輸出什麼,以及它實際輸出的是什麼? – BoBTFish
什麼是'cin.get()'?爲什麼不使用流轉換'radius << cin;'? – wallyk
你會得到什麼? – Engine