输入 n 的值,输出如图所示平行四边形。 ****** ****** ****** ****** ****** ****** n = 6 时的图形
时间: 2023-09-06 12:09:29 浏览: 108
根据提供的参考内容[1]和,可以使用以下程序来输出如图所示的平行四边形:
```
#include <iostream>
using namespace std;
int main() {
int n;
cout << "请输入平行四边形的边长:";
cin >> n;
for(int i=0; i<n; i++) {
for(int j=0; j<n-i-1; j++) {
cout << " ";
}
for(int k=0; k<n; k++) {
if(i==0 || i==n-1 || k==0 || k==n-1) {
cout << "*";
} else {
cout << " ";
}
}
cout << endl;
}
return 0;
}
```
当输入n为6时,输出的图形为:
```
******
******
******
******
******
******
```<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [输出图案-平行四边形](https://blog.csdn.net/dn2021c216/article/details/122071732)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [用python编写一个程序,输入一个数字,输出一个由星号围成的平行四边形](https://blog.csdn.net/zhanghongyi_cpp/article/details/129904570)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文