[c++]代码库
#include "stdafx.h"
#include"iostream"
using namespace std;
const double pi = 3.14;
int main()
{
cout << "Input shape" << endl;
cout << "if circle, input c, if rectangle input r; if square input s" << endl;
char shape;
cin >> shape;
switch (shape)
{
case 'c': double r;
cout << "input radius" << endl;
cin >> r;
cout << " circle area=" << r*r*pi << endl;
break;
case 'r': double len, wid;
cout << "input length and width" << endl;
cin >> len >> wid;
cout << "rectangel=" << (len + wid) * 2 << endl;//补充矩形面积计算
break;
case 's':cout << "input length" << endl;
cin >> len;
cout << "square=" << len*len<< endl;//补充正方形面积计算
break;
default: cout << "input error!" << endl;
break;
}
return 0;
}