#include #include int to_decimal(int val) { if (val >= '0' && val <= '9') return val - '0'; if (val >= 'A' && val <= 'F') return val - 'A' + 10; if (val >= 'a' && val <= 'f') return val - 'a' + 10; return -1; } int main() { int val, char1, char2, val1, val2; while ((val = fgetc(stdin)), !feof(stdin)) if (val == '%') { char1 = fgetc(stdin); if (feof(stdin)) { fprintf(stdout, "%%%c", char1); break; } char2 = fgetc(stdin); val1 = to_decimal(char1); val2 = to_decimal(char2); if (val1 < 0 || val2 < 0) fprintf(stdout, "%%%c%c", char1, char2); else fputc(val1 * 16 + val2, stdout); } else fputc(val, stdout); return 0; }