求助(可互关)
查看原帖
求助(可互关)
528867
Paris_Commune楼主2022/2/24 13:03
#include <bits/stdc++.h>
typedef long long ll;
int m[10010],maxn=0,cnt=1;
using namespace std;
int main(){
	char d[1010][1010],i=1;
	while(gets(d[i]))
	{
		m[i]=strlen(d[i]);
		if(m[i]>maxn)
		maxn=m[i];
		i++;
	}
    i-=1;
	for(int j=1;j<=maxn+2;j++){
		cout<<"*";
	}
	cout<<"\n";
	for(int j=1;j<=i;j++){
		cout<<"*";
		if((maxn%2!=m[i]%2){
			if(cnt==1){
				for(int jj=1;jj<=(maxn-m[j])/2+1;jj++){
					cout<<" ";
				}
			    cout<<d[j];
				for(int jj=1;jj<=(maxn-m[j])/2;jj++){
					cout<<" ";
				}
				cnt=0;
			}
			else{
				for(int jj=1;jj<=(maxn-m[j])/2;jj++){
					cout<<" ";
				}
				cout<<d[j];
				for(int jj=1;jj<=(maxn-m[j])/2+1;jj++){
					cout<<" ";
				}
				cnt=1;
			}
		}
		else{
			for(int jj=1;jj<=(maxn-m[j])/2;jj++){
					cout<<" ";
			}
			cout<<d[j];
			for(int jj=1;jj<=(maxn-m[j])/2;jj++){
					cout<<" ";
			}
		}
		cout<<"*\n";
	}
	for(int j=1;j<=maxn+2;j++){
		cout<<"*";
	}
	return 0;
}
2022/2/24 13:03
加载中...