题解 | #字符串的反码#
字符串的反码
https://www.nowcoder.com/practice/01b7dae14d1b464db5f9259e90d9a35e
#include <stdio.h> #include <string.h> int main(){ char text[81] = {0}; gets(text); int len = strlen(text); char reverse[len]; for (int i = 0; i < len; ++i) { if (text[i] >= 97 && text[i] <= 122){ printf("%c", 122 - (text[i] - 97)); } else if (text[i] >= 'A' && text[i] <= 'Z'){ printf("%c", 90 - (text[i] - 65)); } else{ printf("%c", text[i]); } } return 0; }