Article directory
Question 219.2022 Winter Holiday Ladder Competition Training - 7-5 Blessed Arrival (15 points)
1. The topic
2. Problem solving
Here is a two-dimensional array to store the input characters, pay attention to the input problem
#include <bits/stdc++.h>
using namespace std;
char a[100][100],tmp[100][100];
int main()
{
char ch;
int N;
cin>>ch>>N;
getchar();//这里别忘了用getchar()拿走回车
for(int i=0; i<N; i++)
{
for(int j=0; j<N; j++)
{
scanf("%c",&a[i][j]);//这里不用cin了是因为它不会读空格!
tmp[N-i-1][N-j-1]=a[i][j];
}
getchar();//读回车
}
int flag=1;
for(int i=0; i<N; i++)
{
for(int j=0; j<N; j++)
{
if(a[i][j]!=tmp[i][j])
{
flag=0;
break;
}
}
}
if(flag)
{
printf("bu yong dao le\n");
}
for(int i=0; i<N; i++)
{
for(int j=0; j<N; j++)
{
if(tmp[i][j]==' ')
{
putchar(' ');
}
else
{
putchar(ch);
}
}
putchar('\n');
}
}