2024/09 4

백준 단계별로 풀어보기 (6)

https://www.acmicpc.net/problem/2508325083번 새싹 나의 풀이#include int main(){ std::cout 문자열 사이의 특수 문자들에 유의하여 문자열을 출력한다.https://www.acmicpc.net/problem/30033003번 킹, 퀸, 룩, 비숍, 나이트, 폰 나의 풀이#include #include using namespace std;int main(){ // 킹, 퀸, 룩, 비숍, 나이트, 폰 개수 // 1, 1, 2, 2, 2, 8 이 정상 vector v{ 1, 1, 2, 2, 2, 8 }; vector iv; int a; while (cin >> a) iv.push_back(a); for (int i = 0; i 원래 필요한 개수를 킹, 퀸..

코테 2024.09.25

백준 단계별로 풀어보기 (5) - 문자열

https://www.acmicpc.net/problem/2786627866번 문자와 문자열 나의 풀이#include #include using namespace std;int main(){ string str; cin >> str; int a; cin >> a; cout 단어와 정수가 주어졌을 때, 주어진 단어의 주어진 정수 번째 글자를 출력하는 프로그램이다.string 객체는 [] operator 를 지원하기 때문에 string에 단어를 입력하고, []를 통해서 원하는 글자에 접근했다.https://www.acmicpc.net/problem/27432743번 단어 길이 재기 나의 풀이#include #include int main(){ std::string str; std::cin >> str; st..

코테 2024.09.09

백준 단계별로 풀어보기 (4)

1차원 배열을 사용하는 문제이다. 대부분의 문제에서 std::vector를 사용해서 매우 편하게 풀 수 있었다. https://www.acmicpc.net/problem/1080710807번 개수 세기 나의 풀이#include #include #include using namespace std;int main(){ vector v; v.reserve(100); int n; cin >> n; for (int i = 0; i > a; v.push_back(a); } int key; cin >> key; auto a = v.begin(); int cnt{ 0 }; while (true) { a = find(a, v.end(), key); if (a == v.end()) break; ++cnt; ++a;..

코테 2024.09.06

백준 단계별로 풀어보기 (3)

이번 단계는 반복문이다. 반복을 알맞게 수행하면서도 읽기 쉬운 코드를 만드는 것이 관건이라고 생각한다. https://www.acmicpc.net/problem/27392739번 구구단 나의 풀이#include using namespace std;int main(){ int N; cin >> N; for (int i = 1; i https://www.acmicpc.net/problem/1095010950번 A+B - 3 나의 풀이#include using namespace std;int main(){ int N; cin >> N; for (int i = 0; i > A >> B; cout https://www.acmicpc.net/problem/83938393번 합 나의 풀이#include using ..

코테 2024.09.02