Q

백준 10809

백준 10809번 문제


C code

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
#include <stdio.h>
#include <string.h>

int main(void)
{
char s[101] = "";
char alphabet[26] = "";
char result[26] = "";

for(int i = 0; i < 26; i++)
alphabet[i] = 'a' + i;

for(int i = 0; i < 26; i++)
result[i] = -1;

scanf("%s", s);

for(int i = 0; i < strlen(s); i++)
{
for(int j = 0; j < strlen(alphabet)-1; j++)
{
if(result[j] >= 0)
continue;

if(s[i] == alphabet[j])
result[j] = i;
}
}

for(int i = 0; i < 26; i++)
printf("%d ", result[i]);

return 0;
}