[C++] 프로그래머스 네트워크 DFS, BFS
·
Algorithm/Programmers
#include #include #include using namespace std; int visited[200]; void DFS(int curr, int n, vector computers); int solution(int n, vector computers) { int answer = 0; for(int i = 0; i < n; i++) { if (visited[i] == false) { DFS(i, n, computers); answer++; } } return answer; } void DFS(int curr, int n, vector computers) { queue q; q.push(curr); visited[curr] = true; while(!q.empty()) { int currNod..
[C++] 백준 10282 해킹 다익스트라알고리즘
·
Algorithm/Baekjoon
#include #include #include #include using namespace std; #define INF 987654321 const int maxCom = 10001; int n, d, c, test; void dijkstra(int start, int end, vector *com); int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> test; for (int i = 0; i > n >> d >> c; vector computer[maxCom]; for (int j = 0; j < d; j++)//의존되고 있는 것을 기준으로 push_back한다. { in..
다익스트라 알고리즘
·
Algorithm/Memo
1. 시작한 곳을 dist를 0으로 잡고 시작. 거리비용들의초기값은 INF로 한다. 2. 우선순위 큐를 사용하여 거리비용이 낮은 순으로 탐색 3. 조건은 현재노드에 있는 다음 노드들, 즉 붙어 있는 노드들을 탐색 4. 그 노드들에 대해서 dist보다 현재 노드와 붙어 있는 노드로 가는 거리비용을 합한 값이 작을 경우 값을 적는다. 5. 다음 우선순위 큐가 없을 때까지 반복하면 모든 곳을 최소비용으로 순회하게 된다. 6. 시작지점부터 도착지점까지 최소 비용을 구하는 문제에 사용. 도움 사이트 : yabmoons.tistory.com/364 [ 다익스트라 알고리즘 ] 개념과 구현방법 (C++) 그래프 알고리즘에서 '최소 비용'을 구해야 하는 경우 사용할 수 있는 대표적인 알고리즘으로는 '다익스트라 알고리즘'..
Range기반 for루프
·
C++/Basic
double prices[5] = {4.99, 10.99, 6.87, 3.14, 22.3}; for(double x : prices) cout
Unreal 문자열의 추가
·
Game Programming/Unreal
void AC01_Property::BeginPlay() { Super::BeginPlay(); FString strl; strl.Append("A :"); strl.Append(FString::FromInt(A)); strl.Append(", "); } Append는 변수에 문자열을 +=같이 추가해준다. FString::FromInt()는 int를 문자열로 바꾸어 준다.
문자열의 비교
·
C++/Basic
#include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string x = "mate"; char y[5] = "mate"; if (x == "mate")//true { cout