Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
51 | 晁鑫 | 字符串反转 | C++ | Accepted | 9 MS | 744 KB | 552 | 2020-08-09 21:26:17 |
#include <iostream> #include <cstring> using namespace std; int main() { int i,j,k,n,len,temp = 0,t = 0; char str[1001] = {0}; cin >> n; getchar(); for(i = 0; i < n ; i++) { t = 0; gets(str); len = strlen(str); for(j = 0; j < len;j++) { if((str[j] == ' ')) { for(k = j; k > t;k--) { cout << str[k-1]; } cout << ' '; t = j+1; } if((str[j+1] == '\0')) { for(k = j+1; k > t;k--) { cout << str[k-1]; } } } cout <<endl; } return 0 ; }