题解 | #字符串连接#朴实无华的o(n^2)
字符串连接
https://www.nowcoder.com/practice/40d83e5509b04d20825ae68fe35e9ca8
#include <stdio.h> using namespace std; int main() { char a[1000] = { 0 }; while (fgets(a, sizeof(a), stdin)) { for (int i = 0; a[i] != '\0'; i++) { if (a[i] == ' ') { for (int j = i; a[j] != '\0'; j++) { a[j] = a[j + 1]; } } } printf("%s", a); } return 0; }