AcWing 3154. 打印大X(只ac了6个有大佬看看哪儿错了嘛)
原题链接
简单
作者:
xrzscxy
,
2021-03-29 15:21:51
,
所有人可见
,
阅读 293
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 1010;
int n,m;
char s[N][N];
int main(){
cin >> m >> n;
int k = n+m-1;//k是矩阵的宽
for(int i = 1;i <= n;i++){
for(int j = 1;j <= k;j++){
s[i][j] = '.';
}
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= k;j++){
if(j == i || j == k-m-(i-1)+1){
for(int x = j;x <= j+m-1;x++){
s[i][x] = '*';
}
}
}
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= k;j++){
cout << s[i][j];
}
cout << endl;
}
return 0;
}