PAT 1009. 说反话 (20)
代码
#include<bits/stdc++.h>
using namespace std;
char s[100];
string b[100];
int main()
{
int i,j,k,t;
gets(s);
int n=strlen(s);
cout<<n<<endl;
for(i=0,j=0;i<n;i++)
{
if(s[i]==' ')
{
b[j][k]='\0';
j++; k=0;
}
else
{
b[j][k++]=s[i];
}
}
for(t=j-1;t>=0;t--)
{
cout<<b[t]<<endl;
}
return 0;
}
anytime you feel the pain.hey,refrain.don't carry the world upon your shoulders