字符串单词倒排

今天编了老久,最终还是在众多大佬的帮助下把这道题给ak了!!!收工!!!

#include<string>
#include<bits/stdc++.h>
using namespace std;
string a,b,c,d;
int x,y,z,l;
char A[520],B[520][520],C[520],D[520];
int main()
{
    cin.getline(A,520);
    for(int i=0;i<strlen(A);i++)
    {
        if(A[i]!=' ')
        {
            B[l][x]=A[i];
            x++;
        }
        else
        {
            l++;
            x=0;
        }
    }
    for(int j=l;j>=0;j--)
        printf("%s ",B[j]);
    return 0;
}

  

猜你喜欢

转载自www.cnblogs.com/5t2y0/p/9236182.html
今日推荐