[백준 12919번] A와 B 2 (C++)
문제링크 : https://www.acmicpc.net/problem/12919 #include using namespace std; string S, T, temp = ""; int result = 0; void func(string s, string t) { if (s == t) { result = 1; return; } //바꿀 수 있을 때 if (s.size() >= t.size()) { return; } //바꿀 수 없을 때 if (t[t.size() - 1] == 'A') //맨 마지막이 A이면 { temp = t; temp.erase(temp.size() - 1); //A를 지우고 재귀 func(s, temp); } if (t[0] == 'B') //맨 처음이 B이면 { temp = t; t..
백준/골드
2023. 2. 5. 16:38
[백준 5177번] 출력 형식이 잘못되었습니다 (C++)
문제링크 : https://www.acmicpc.net/problem/5177 #include using namespace std; int k; string s1, s2; string func(string s) { for (int i = 0; i = 1 && s[s.length() - 1] == ' ') //문자열 맨뒷부분이 공백이면 지우기 s.pop_back(); for (int i = 1; i < s.length(); i++) //특수문자 앞이나 뒤가 공백이면 지우기 { char a = s[i - 1], b = ..
백준/실버
2023. 2. 5. 16:36