50 lines
969 B
C++

#include<iostream>
int main()
{
std::cout << "输入正方形的边长:";
float a, b, c, d;
std::cin >> a;
std::cout << "输入长方形的长和宽:";
std::cin >> b >> c;
std::cout << "输入三角形的高:";
std::cin >> d;
std::cout << "正方形:" << std::endl;
for (int i = 0; i < a; i++) {
for (int j = 0; j < a; j++) {
if (i == a - 1 || i == 0 || j == a - 1 || j == 0) {
std::cout << "*";
}
else {
std::cout << " ";
}
}
std::cout << std::endl;
}
std::cout << "长方形:" << std::endl;
for (int i = 0; i < c; i++) {
for (int j = 0; j < b; j++) {
if (i == c - 1 || i == 0 || j == b - 1 || j == 0) {
std::cout << "*";
}
else {
std::cout << " ";
}
}
std::cout << std::endl;
}
std::cout << "三角形:" << std::endl;
for (int i = 0; i < d; i++) {
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i || i == 0 || i == d - 1) {
std::cout << "*";
}
else {
std::cout << " ";
}
}
std::cout << std::endl;
}
}