所以我昨天刚开始 C++,我有相当多的 java 经验,所以这就是原因,我尝试运行这段代码,由于某种原因 while 循环没有循环,我尝试将 if break 语句从 更改ask==false为ask=false,这最终会导致无限循环,甚至不接受用户输入。
这是代码:
#include <iostream>
#include <math.h>
using namespace std;
int main(){
double raduis;
const double pi = 3.14;
bool ask;
while(true){
cout << "Enter the raduis of the circle:"<< endl;
cin >> raduis;
double circ = 2*pi*raduis;
double area = pi*pow(raduis,2);
cout << "The Circumference of the circle is: "<< circ <<endl;
cout << "The Area of the circle is: "<< area<<endl;
cout <<"Would you like to …Run Code Online (Sandbox Code Playgroud)