#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
int N;
cin>>N;
getchar();
while(N--)
{
int m=0;
string str;
getline(cin,str);
for(int i=0;i<str.length();i++)
{
if(str[i]==' ')
{
for(int j=i-1;j>=m;j--)
{
cout<<str[j];
}
cout<<" ";
m=i+1;
}
}
for(int j=str.length()-1;j>=m;j--)
{
cout<<str[j];
}
cout<<endl;
}
return 0;
}
本文展示了一个使用C++编程语言实现的字符串逆序输出的示例代码。通过读取输入的字符串数量,然后逐个读取并逆序输出每个字符串,此程序展示了基本的字符串操作和控制流程。
225

被折叠的 条评论
为什么被折叠?



