题解 | #输出指定长度子串#
输出指定长度子串
https://www.nowcoder.com/practice/56c6fb8231a44ed8ab91ac231f7b2c63
#include <stdio.h> #include <string.h> int main() { char arr[10000]; gets(arr); int n; scanf("%d", &n); int len = strlen(arr); if (n <= 0 || n > len) { printf("-1"); } else { for (int i = 0; i <= len - n; i++) { int j = i; while (j < n + i) { printf("%c", arr[j]); j++; } printf(" "); } } return 0; }