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]='';
            j++;   k=0;
        }
        else
        {
            b[j][k++]=s[i];
        }
    }
    
    for(t=j-1;t>=0;t--)
    {
        cout<<b[t]<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/gaoss/p/5365964.html