Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
92849 | 刘轻松 | 单词翻转 | C++ | Accepted | 1 MS | 276 KB | 422 | 2024-10-06 15:23:59 |
#include<iostream> #include<cstring> using namespace std; int main(){ string s; int a=0,j; getline(cin,s); for(int i=0;i<s.size();i++){ if(s[i]!=' '){ a++; } if(s[i]==' '){ j = i-1; while(a>0){ cout<<s[j]; j--; a--; } cout<<' '; } if(i==s.size()-1){ j=i; while(a>0){ cout<<s[j]; j--; a--; } } } return 0; }