#2091
典型的PE气死人
这里注意几个点
字符读取记得换行符的处理
输出的时候记得空一行的操作
记得不是一直输出空格到2*n-1,输出字符之后就没有空格了
用excel做了个表格容易看清楚下标关系
题目直达
AC代码
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main() {
char x;
int n;
int k=0;
while(cin>>x){
if(x=='@'){
return 0;
}
cin>>n;
getchar();//每次有字符输入都要记得读取换行符
//这里可以解决PE问题,是先读取字符之后换行的,不是直接在每个三角形输出之后换行
//这么坑的吗?
if(k!=0){
cout<<endl;
}
k++;
for(int i=0;i<n-1;i++){
for(int j=0;j<n+i;j++){
if(j==n-1-i || j==n-1+i){
cout<<x;
}
else{
cout<<" ";
}
}
cout<<endl;
}
for(int i=0;i<2*n-1;i++){
cout<<x;
}
cout<<endl;
}
return 0;
}