#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
char message[1000], reversedMessage[1000];
int i, length;
// รับข้อความจากผู้ใช้
// ลบ newline ที่ fgets อ่านเข้ามา
if (len > 0 && message[len - 1] == '\n') {
message[len - 1] = '\0';
}
// แปลงข้อความให้เป็นตัวพิมพ์เล็ก
for (i = 0; message[i]; i++) {
message[i] = tolower(message[i]);
}
// คำนวณความยาวของข้อความ
// กลับข้อความ
for (i = 0; i < length; i++) {
reversedMessage[i] = message[length - i - 1];
}
reversedMessage[length] = '\0'; // เพิ่ม null terminator
// พิมพ์ข้อความที่กลับแล้ว
printf("%s\n", reversedMessage
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPGN0eXBlLmg+CgppbnQgbWFpbigpIHsKICAgIGNoYXIgbWVzc2FnZVsxMDAwXSwgcmV2ZXJzZWRNZXNzYWdlWzEwMDBdOwogICAgaW50IGksIGxlbmd0aDsKCiAgICAvLyDguKPguLHguJrguILguYnguK3guITguKfguLLguKHguIjguLLguIHguJzguLnguYnguYPguIrguYkKICAgIHByaW50ZigiRW50ZXIgYSBtZXNzYWdlOiAiKTsKICAgIGZnZXRzKG1lc3NhZ2UsIHNpemVvZihtZXNzYWdlKSwgc3RkaW4pOwoKICAgIC8vIOC4peC4miBuZXdsaW5lIOC4l+C4teC5iCBmZ2V0cyDguK3guYjguLLguJnguYDguILguYnguLLguKHguLIKICAgIHNpemVfdCBsZW4gPSBzdHJsZW4obWVzc2FnZSk7CiAgICBpZiAobGVuID4gMCAmJiBtZXNzYWdlW2xlbiAtIDFdID09ICdcbicpIHsKICAgICAgICBtZXNzYWdlW2xlbiAtIDFdID0gJ1wwJzsKICAgIH0KCiAgICAvLyDguYHguJvguKXguIfguILguYnguK3guITguKfguLLguKHguYPguKvguYnguYDguJvguYfguJnguJXguLHguKfguJ7guLTguKHguJ7guYzguYDguKXguYfguIEKICAgIGZvciAoaSA9IDA7IG1lc3NhZ2VbaV07IGkrKykgewogICAgICAgIG1lc3NhZ2VbaV0gPSB0b2xvd2VyKG1lc3NhZ2VbaV0pOwogICAgfQoKICAgIC8vIOC4hOC4s+C4meC4p+C4k+C4hOC4p+C4suC4oeC4ouC4suC4p+C4guC4reC4h+C4guC5ieC4reC4hOC4p+C4suC4oQogICAgbGVuZ3RoID0gc3RybGVuKG1lc3NhZ2UpOwoKICAgIC8vIOC4geC4peC4seC4muC4guC5ieC4reC4hOC4p+C4suC4oQogICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgcmV2ZXJzZWRNZXNzYWdlW2ldID0gbWVzc2FnZVtsZW5ndGggLSBpIC0gMV07CiAgICB9CiAgICByZXZlcnNlZE1lc3NhZ2VbbGVuZ3RoXSA9ICdcMCc7IC8vIOC5gOC4nuC4tOC5iOC4oSBudWxsIHRlcm1pbmF0b3IKCiAgICAvLyDguJ7guLTguKHguJ7guYzguILguYnguK3guITguKfguLLguKHguJfguLXguYjguIHguKXguLHguJrguYHguKXguYnguKcKICAgIHByaW50ZigiJXNcbiIsIHJldmVyc2VkTWVzc2FnZSk7CgogICAgcmV0dXJuIDA7Cn0K