追问:
我应该把
getchr()
加到哪里?
#include<iostream>
using namespace std;
int main()
{
double a,b,r,c;
int i;
const double pi=3.1415926;
cout<<"请输入以下计算编号:1,长方形面积 。2,圆的面积。3,正方形的面积。\n";
cin>>i;
if (i>=3||i<=0)
cout<<"你TM在玩我?!只能输入1到3的任一整数"<<endl;
switch(i)
{
case 1:
cout<<"请输入长方形的长和宽\n";
cout<<"长=";
cin>>a ;
cout<<endl;
cout<<"宽=";
cin>>b ;
cout<<endl;
cout<<"长方形的面积为:"<<a*b<<endl;
case 2:
cout<<"请输入圆的半径r
\n";
cin>>r;
cout<<"半径为"<<r<<"的圆的面积为"<<r*r*pi<<endl;
case 3:
cout<<"请输入正方形的周长c.\n"<<"c="<<endl;
cin>>c;
cout<<"周长为"<<c<<"正方形的面积为"<<(c/4)*(c/4)<<endl;
break;
}
return 0;
}