Notice
Recent Posts
Recent Comments
Link
«   2025/02   »
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
Tags
more
Archives
Today
Total
관리 메뉴

main

[백준 - 10871번] X보다 작은 수 본문

Algorithm

[백준 - 10871번] X보다 작은 수

1984 2022. 1. 23. 00:26
  • 아스키코드 (ASCII code)
  • map 사용
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(void)
{
	string S;
	map<char, int> m;

	for (char i = 97; i <= 122; i++)
	{
		m.insert(make_pair(i, -1));
	}

	cin >> S;

	for (int i = 0; i < S.length(); i++)
	{
		if(m[S[i]] == -1) m[S[i]] = i;
	}

	for (map<char, int>::iterator it = m.begin(); it != m.end(); ++it)
	{
		cout << it -> second << ' ';
	}

	return 0;
}

 

[참고 자료]

https://codedragon.tistory.com/2547

728x90

'Algorithm' 카테고리의 다른 글

[백준 - 18111번] 마인크래프트  (0) 2022.01.23
[백준 - 1085번] 직사각형에서 탈출  (0) 2022.01.23
[백준 - 3052번] 나머지  (0) 2022.01.23
[백준 - 10951번] A+B - 4  (0) 2022.01.22
[백준 - 10818번] 최소, 최대  (0) 2022.01.22
Comments