题目链接:https://codeforces.com/contest/14/problem/A
找到x轴和y轴的最大和最小边界输出子矩阵
#include <iostream>
using namespace std;
static const int MAXN=50+5;
int n,m;
char g[MAXN][MAXN];
int main()
{
scanf("%d%d",&n,&m);for(int i=1;i<=n;i++)scanf("%s",g[i]+1);int minx=n+1,maxx=0;int miny=m+1,maxy=0;for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(g[i][j]=='*'){
minx=min(minx,i);maxx=max(maxx,i);miny=min(miny,j);maxy=max(maxy,j);}for(int i=minx;i<=maxx;i++){
for(int j=miny;j<=maxy;j++)printf("%c",g[i][j]);printf("\n");}return 0;
}