#include "pch.h" #include<iostream> using namespace std; const float PI = 3.1415926; int main() { int iType; float readius, a, b; while (true){ cout << "图形的类型为?(1-圆形 2-长方形 3-正方形)"; cin >> iType; switch (iType) { case 1: cout << "请输入圆形的直径"; cin >> readius; cout << "圆的面积为" << readius * PI << "平方厘米" << endl; break; case 2: cout << "矩形的长为:"; cin >>a; cout << "矩形的宽位"; cin >> b; cout << "矩形的面积为:" << a * b << "平方厘米" << endl; break; case 3: cout << "请输入正方形的边长"; cin >> a; cout << "正方形面积为" << a * a << "平方厘米" << endl; } } }
原文地址:https://www.cnblogs.com/zhangdingqu/p/10326061.html
时间: 2024-11-10 08:08:21