赞
踩
给定一个字符,用它构造一个底边长5个字符,高3个字符的等腰字符三角形。
输入只有一行,包含一个字符。
该字符构成的等腰三角形,底边长5个字符,高3个字符。
*
- *
- ***
- *****
- #include<bits/stdc++.h>
- using namespace std;
- char c;
- int f(int x){
- x = x * 2;
- for(int i = 1;i<=x;i+=2){
- int y = (x - i) / 2;
- for(int j = 1;j<=y;j++){
- cout<<' ';
- }
- for(int j = 1;j<=i;j++){
- cout<<c;
- }
- cout<<endl;
- }
- }
- int main(){
- cin>>c;
- int n=3;
- f(n);
- return 0;
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。