알고리즘 문제 풀이/백준 온라인 저지
백준 10809번: 알파벳 찾기 (C++)
Hugxy
2019. 9. 25. 21:20
https://www.acmicpc.net/problem/10809
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 | #pragma warning(disable :4996) #include<iostream> #include<string> using namespace std; int alp[26]; int main(void) { //ios::sync_with_stdio(false); cin.tie(0); string str; cin >> str; for (int i = 0; i < 26; i++) alp[i] = -1; for (int i = 0; i < str.length(); i++) { if (alp[str[i] - 'a'] == -1) alp[str[i] - 'a'] = i; } for (int i = 0; i < 26; i++) if (alp[i] >= 0) cout << alp[i] << ' '; else cout << -1 << ' '; return 0; } | cs |