Develop/Algorithm4 DP #include using namespace std; long long d[100]; long long fibo(int x) { cout 2024. 2. 15. 이진탐색 #include using namespace std; // 이진 탐색 소스코드 구현(반복문) int binarySearch(vector& arr, int target, int start, int end) { while (start target) end = mid - 1; // 중간점의 값보다 찾고자 하는 값이 큰 경우 오른쪽 확인 else start = mid + 1; } return -1; } int n, target; vector arr; int main(void) { // n(원소의 개수)와 target(찾고자 하는 값)을 입력 받기 cin >> n >> target; // 전체 원소 입력 받기 for (int i = 0; i > x; arr.push_ba.. 2024. 2. 13. BFS 너비우선탐색 #include using namespace std; bool visited[9]; vector graph[9]; // BFS 함수 정의 void bfs(int start) { queue q; q.push(start); // 현재 노드를 방문 처리 visited[start] = true; // 큐가 빌 때까지 반복 while(!q.empty()) { // 큐에서 하나의 원소를 뽑아 출력 int x = q.front(); q.pop(x); cout 2024. 2. 13. DFS 깊이우선탐색 #include using namespace std; bool visited[9]; vector graph[9]; // DFS 함수 정의 void dfs(int x) { // 현재 노드를 방문 처리 visited[x] = true; cout 2024. 2. 13. 이전 1 다음