blob: 69068fa91f3584c2cb6d5480167c5fcb644a76c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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);
}
|