编写一个c++程序,提示用户输入圆的半径,然后调用内联函数circleArea计算圆面积
1个回答
展开全部
//#include "stdafx.h"//If the vc++6.0, with this line.
#include <iostream>
using namespace std;
inline double circleArea(double r){
return 3.1415926*r*r;
}
int main(int argc,char *argv[]){
double x;
cout << "Input x(R:x>=0)...\nx=";
if(!(cin >> x) || x<0){
cout << "Input error, exit...\n";
return 0;
}
cout << "The area of this circle is " << circleArea(x) << endl;
return 0;
}
运行样例:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询