起初没有加后面for循环中的if语句,而且没有上面的双重for循环一直WA,注意些就行,字符串太神奇了,一不小心就错了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<algorithm>
using namespace std;
int main()
{
char s[105][105];
for(int i=0;i<105;i++)
for(int j=0;j<105;j++)
s[i][j]='\0';
int maxn=0;
int i=0;
while(gets(s[i]))
{
maxn=max(maxn,(int)strlen(s[i]));
i++;
}
// cout<<maxn<<endl;
for(int j=0;j<maxn;j++)
{
for(int k=i-1;k>=0;k--)
{
if(s[k][j]=='\0'&&k!=0)
cout<<' ';
else
cout<<s[k][j];
}
cout<<endl;
}
return 0;
}