关于c++的问题,求大佬球球了

2,编写程序,输入-句英语,将句中所有单词的顺序颠倒输出。如输入Hello World Here 1Come,则输出为ComeHere WordHelo

供参考:

#include<stdio.h>
int main()
{
    char s[80][80];
    int i=0,j;
    while(1)
    {
       scanf("%s",s[i++]);
       if((getchar())=='\n') break;
    }
    for(j=i-1;j>=0;j--)
        printf("%s%c",s[j],j!=0?' ':'\n');
    
    return 0;
}

 

#include<stdio.h>
#include<stdlib.h>
#define N 6

void reverse(int b[],int n)
{
    int i;
    int temp;
    for (i=0;i<N/2;i++) {
        temp =b[0];
        b[0]=b[n-1];
        b[n-1]=temp;
    }
}
int main(void)
{
    int i;
    int arr[N]={12,34,20,56,30,50};
    reverse(arr,N);
    for (i=0;i<N;i++)
    {
    printf("%5d",arr[i]);
    
    }
    return EXIT_SUCCESS;
}

代码如下:

#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

void SplitStr(std::string pStr, char ch,std::vector<std::string>& vReturn)
{
	int nStartPos=0;
	int nEndPos=0;
	while((nEndPos = pStr.find(ch,nStartPos))> 0)
	{
		vReturn.push_back(pStr.substr(nStartPos,nEndPos - nStartPos));
		nStartPos = nEndPos+1;
	}
	nEndPos=pStr.find('\0',0);
	vReturn.push_back(pStr.substr(nStartPos,nEndPos-nStartPos));
}

int main()
{
	printf("请输入一句英文:");
	char buf[80] = {0};
	gets(buf);

	vector<string> vout;
	SplitStr(buf,' ',vout);

	for (int i = vout.size()-1; i >= 0; i--)
	{
		printf("%s ",vout.at(i).c_str());
	}
	

	getchar();
	getchar();
	return 0;
}