#include #include #include char getWrong(char *line) { char *middle = line + strlen(line)/2; char *a = line; char *b = middle; for (char *a = line; a < middle; a++) { for (char *b = middle; *b != '\n'; b++) { if ( *a == *b ) return *b; } } } int main() { char *line = NULL; size_t len; int prios = 0; while (getline(&line, &len, stdin) >= 0) { char wrong = getWrong(line); printf("%c", wrong); int prio; if ( wrong >= 97 && wrong <= 122 ) prio = wrong - 96; else prio = wrong - 64 + 26; printf("%d", prio); prios += prio; } printf("\n%d\n", prios); }