?
#include <stdio.h>
#include <string.h>char* substr(char *s, int startloc, int len) {static char result[51]; // 定義一個足夠大的靜態數組來存儲結果static char result1[] = {'N','U','L','L','\0'};int i, j;// 檢查startloc是否在字符串的范圍內if (startloc < 1 || startloc > strlen(s)) {return result1; // 如果不在范圍內,返回NULL}// 計算實際要復制的子串長度int actual_len = (startloc + len-1 < strlen(s)) ? len : (strlen(s) - startloc+1);// 復制子串到結果數組for (i = startloc-1, j = 0; i < startloc + actual_len-1; i++, j++) {result[j] = s[i];}result[j] = '\0'; // 添加字符串結束符return result; // 返回結果
}int main() {int t;scanf("%d",&t);while(t--){char a[100];scanf("%s",a);int x,y;scanf("%d %d",&x,&y);printf("%s\n", substr(a, x, y));}return 0;
}