2764: 练38.2 大写字母 Y

内存限制:64 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:24 解决:11

题目描述

自从小蓝学会编程之后,他酷爱用编程的方式写字母。你能帮助他写出字母 "$Y$" 吗?

输入

一行一个整数 $n$($1< n < 50$)。

输出

输出高度为 $2×n−1$ 行的大写字母 "$Y$"。
提示: 第一行第一颗左侧无多余空格,每行最后一颗 "$*$" 后无多余空格。

样例输入 复制

4

样例输出 复制

*     *
 *   *
  * *
   *
   *
   *
   *

提示

#include<bits/stdc++.h>
using namespace std;
int n,l,r;
int main(){
    cin>>n;
    l=1,r=2*n-1;
    for (int i=1;i<=n;i++,l++,r--) {
    	for(int j=1;j<=2*n-1;j++) {
    		if(j==l||j==r) cout<<"*";
    		else cout<<' ';
		}
		cout<<endl;
	}
	for(int i=1;i<n;i++) {
		for(int j=1;j<n;j++) 
		    cout<<' ';
		cout<<'*'<<endl;
	} 
	    
	return 0;
}