Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
44122 何泓苇 单词翻转 C++ Accepted 2 MS 276 KB 365 2023-02-01 17:06:46

Tests(10/10):


Code:

#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main () { string a; getline(cin,a); int n=a.length(); int i_t=0; for(int i=0; i<n; i++) { if(a[i]==' ') { for(int j=i-1; j>=i_t; j--) { cout<<a[j]; } cout<<" "; i_t=i+1; } } for(int j=n-1; j>=i_t; j--) { cout<<a[j]; } return 0; }