题解 | #多组_字符串_T组形式#
多组_字符串_T组形式
https://www.nowcoder.com/practice/35f6f4e9173943e3b3f462b697fefd8b
#include <stdio.h> #include <stdlib.h> void printReversedString(int length) { char* s = (char*)malloc((length + 1) * sizeof(char)); for(int i = 0; i < length; i++) { char temp; scanf("%c",&temp); s[length -i -1] = temp; } s[length] = '\0'; // Null-terminate the string to make sure the string ends printf("%s\n",s); free(s); } int main() { int t; scanf("%d\n",&t); while(t > 0) { int n; scanf("%d\n", &n); printReversedString(n); t -- ; } }