mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-14 07:38:42 +00:00
96d4a3ecf7
Due to historical reasons, the code is in subfolder "1". With SVN removal, we place the code back and remove the annoying "1" folder.
56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
#include<cstdio>
|
|
#include<cstdlib>
|
|
#include<cstring>
|
|
#include<cmath>
|
|
#include<algorithm>
|
|
using namespace std;
|
|
typedef long long LL;
|
|
int main()
|
|
{
|
|
//freopen("1.in","r",stdin);
|
|
char c,last;
|
|
int nSpace=0,nR=0,first;
|
|
while(1)
|
|
{
|
|
last=c,c=getchar();
|
|
if(c==EOF)
|
|
{
|
|
if(last!='\n')
|
|
putchar('\n');
|
|
break;
|
|
}
|
|
else if(c!='\r'&&c!=' ')
|
|
{
|
|
if(c!='\n'&&first==0)
|
|
{
|
|
for(int j=1;j<=nSpace;++j)
|
|
putchar(' ');
|
|
for(int j=1;j<=nR;++j)
|
|
putchar('\r');
|
|
}
|
|
else if(c!='\n')
|
|
{
|
|
for(int j=1;j<=nR;++j)
|
|
putchar('\r');
|
|
for(int j=1;j<=nSpace;++j)
|
|
putchar(' ');
|
|
}
|
|
nSpace=nR=0;
|
|
putchar(c);
|
|
}
|
|
else if(c==' ')
|
|
{
|
|
++nSpace;
|
|
if(nR==0)
|
|
first=0;
|
|
}
|
|
else
|
|
{
|
|
++nR;
|
|
if(nSpace==0)
|
|
first=1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|