9093
-
9093) 단어 뒤집기 c++백준코딩일기 2020. 11. 19. 16:00
문제 ) www.acmicpc.net/problem/9093 9093번: 단어 뒤집기 첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, 문장이 하나 주어진다. 단어의 길이는 최대 20, 문장의 길이는 최대 1000이다. 단어와 단어 사이에는 www.acmicpc.net 풀이 ) 1. cin 으로 N 이라는 테스트 케이스를 받아온 후 버퍼를 비운다. 2. getline 으로 한 줄 씩 입력 받는다. 입력받은 문자열을 input 이라고 한다면. input += ' ' 입력받은 문자열 뒤에 띄어쓰기를 하나 더 붙여준다. 3. 스택에 한 문자씩 넣는데, 띄어쓰기를 만나면 가장 위에서 부터 팝을 한다. 코드 ) #include #include using namespac..