Run ID:93511

提交时间:2024-10-17 15:12:35

#include <stdio.h> #include <string.h> #define MAX_LENGTH 101 int main() { int C; scanf("%d", &C); // 读取测试数据的组数 while (C--) { char input[MAX_LENGTH]; scanf("%s", input); // 读取待破译的字符串 char output[MAX_LENGTH]; int outputIndex = 0; int num=0,tmp; for (int i = 0; input[i] != '\0'; i++) { if (input[i] >= '0' && input[i] <= '9') { tmp = input[i] - '0'; num = num*10 + tmp; } else if (input[i] == '#') { output[outputIndex++] = num+64; output[outputIndex++] = ' '; num =0; } else if (input[i] == '-') { // 忽略'-' output[outputIndex++] = num+64; num =0; continue; } } output[outputIndex++] = num+64; output[outputIndex] = '\0'; // 确保输出字符串以空字符结尾 printf("%s\n", output); // 输出破译后的文本 } return 0; }