2020/3/13_C++实验课

#include <iostream>
#include <cmath>
using namespace std;
double calcualateCircle(double r = 0) {
    return acos(-1) * r * r;
}

double calcualateRectangle(double len = 0, double high = 0) {
    return len * high;
}


double calcualateSquare(double len = 0) {
    return len * len;
}
int main()
{
    cout << "请输入用户选择图形的类型" << endl;
    cout << "1.圆形   2.长方形   3.正方形" << endl;
    int choice;
    cin >> choice;
    switch (choice){
        case 1:
            cout << "请输入圆形的半径:" << endl;
            double r;
            cin >> r;
            cout << calcualateCircle(r) << endl;
            break;
        case 2:
            cout << "请输入长方形的宽和高:" << endl;
            double len, high;
            cin >> len >> high;
            cout << calcualateRectangle(len, high) << endl;
            break;
        case 3:
            cout << "请输入正方形的边长:" << endl;
            double l;
            cin >> l;
            cout << calcualateSquare(l) << endl;
            break;
        default:
            cout << "输入错误" << endl;
    }
    return 0;
}
作者:LightAc
出处:https://www.cnblogs.com/lightac/
联系:
Email: dzz@stu.ouc.edu.cn
QQ: 1171613053
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/lightac/p/12484376.html