题目描述
现给出一个N*N(长和宽都为N)全由小写英文字母组成的方阵,要求将每一行都按照字母表顺序从小到大排序后上下颠倒之后输出。
输入
输入包括N+1行,第一行为一个整数N,接下来为N行长度为N的字符串。其中0<N<=100,所有字母均为小写字母。
输出
每一行排序后,并且上下颠倒后的方阵。
样例输入
3 abc edf igh
样例输出
ghi def abc
#include<iostream>
#include<stack>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main()
{
int n;
string str1;
vector<string> vector1;
stack<string> stack1;
scanf("%d",&n);
while(n--)
{
cin>>str1;
sort(str1.begin(),str1.end());
stack1.push(str1);
}
while(!stack1.empty())
{
cout<<stack1.top()<<endl;
stack1.pop();
}
return 0;
}