목록C++ (16)
컴공댕이 공부일지
매번 헷갈렸어서 확실히 정리했다. 1. 벡터를 값으로 전달하기이렇게 하면 함수 내에서 벡터의 복사본이 생성됩니다. #include #include void processVector(std::vector vec) { // 벡터 처리 for (int i : vec) { std::cout
백준 10814번 나이순 정렬 (실버 5) https://www.acmicpc.net/problem/10814 (정답 코드) #include #include #include using namespace std; typedef pair p; bool cmp(const p &a, const p &b) { // 나이순 정렬 if(a.first!=b.first) { return a.first < b.first; } // 나이가 같으면 변화없이 그대로 ! else { return false; // 원래 순서 유지 ! } } void sortUser(vector& user) { // 입력 순서를 보존하는 안정적인 정렬을 보장하는 sort_stable stable_sort(user.begin(), user.end()..

백준 15685 드래곤 커브 (골드 3) 문제링크 https://www.acmicpc.net/problem/15685 15685번: 드래곤 커브 첫째 줄에 드래곤 커브의 개수 N(1 ≤ N ≤ 20)이 주어진다. 둘째 줄부터 N개의 줄에는 드래곤 커브의 정보가 주어진다. 드래곤 커브의 정보는 네 정수 x, y, d, g로 이루어져 있다. x와 y는 드래곤 커 www.acmicpc.net (정답 코드) #include #include using namespace std; const int MAX_SIZE = 100; //맵은 최대 100,100 bool visited [MAX_SIZE+1][MAX_SIZE+1]={false,}; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, ..

2023. 11. 3 일자 이화여대 알고리즘 튜터링 프로그램, 알튜비튜의 수업 내용 정리본입니다. 🔍이분 탐색 ( BinarySearch )이란 ? 업다운 게임을 생각하면 된다 ! 중간값과 찾아야하는 값을 비교해가며, 배열의 크기를 절반으로 줄이며 답을 찾는 알고리즘으로 반복문으로 구현하며, 시간 복잡도는 O(logN) 알고리즘 사용 전, 반드시 배열을 정렬해야 한다 !! +) 이분 탐색의 대상 원소들을 트리에 넣으면 바이너리서치트리(binary search tree) ! BST를 중위 순회 (inorder) 하면 정렬된 순서의 배열이 나온다. 이미지 출처 : https://velog.io/@reyang/C-%EC%84%A0%ED%98%95-%ED%83%90%EC%83%89-%EC%9D%B4%EC%A7%..

https://solved.ac/problems/sprout 1) 입력값의 합 출력하기 백준 1000번 #include int main() { int a,b=0; scanf("%d",&a); scanf("%d",&b); printf("%d", a+b); return 0; } 2) 입력값의 차 출력하기 백준 1001번 #include int main() { int a,b=0; scanf("%d",&a); scanf("%d",&b); printf("%d", a-b); return 0; } 3) 입력값의 곱 출력하기 백준 10998번 #include int main() { int a,b=0; scanf("%d",&a); scanf("%d",&b); printf("%d", a*b); return 0; } 4) ..
https://solved.ac/problems/sprout 1) Hello World 출력하기 2557번 #include int main() { printf("Hello World!"); return 0; } 2) 오늘 날짜 출력하기 10699번 #include int main() { printf("2022-08-31"); return 0; } 3) 내 아이디와 맞힌 문제 수 출력하기 7287번 #include int main() { printf("7\nsomi5488"); return 0; } 4) 고양이 그림 출력하기 10171번 #include int main() { printf("\\ /\\ \n ) ( \')\n( / ) \n \\(__)|"); return 0; } 5) 강아지 그림 출력하기..