%include "io64.inc"section .textglobal mainmain: mov rbp, rsp; for correct debugging ;write your code here ;1~100사이 값중 홀수면 1 짝수면 0출력 GET_DEC 1, a mov bl, 1 and [a], bl cmp [a], byte 1 je LABEL_EQUAL PRINT_DEC 1, 0 jmp LABEL_NOT_EQUALLABEL_EQUAL: PRINT_DEC 1, 1 LABEL_NOT_EQUAL: xor rax, rax retsection .bss g resb 10 ; 변수이름 크기 개 a resb 1SASM 프로그램..
#include "pch.h"#include "Logger.h"LogPrintf::LogPrintf() { printf("* Log create : printf log mode\n");}void LogPrintf::log(const WCHAR* logStr) { printf("%ws", logStr);}//------------------------------------------------------------------------------------------//LogFile::LogFile(xml_t* config) { xmlNode_t* root = config->FirstChildElement("App")->FirstChildElement("Log"); xmlNode_t* elem = root..
#pragma once#include #include "pch.h"//string 초기화#define UNDEFINE_NAME L"Undefine_Name" // wchar_t타입 wide_char//snprintf 재정의, 안전을 위해 array 사용을 기본으로 합니다.#define snprintf(dst, format, ...) _snprinf_s(dst.data(), dst.size(), _TRUNCATE, format, __VA_ARGS__) // __VA_ARGS__ = 가변인자 ...이랑 같이 쓰임 (매크로에서만 쓰임)#define snwprintf(dst, format, ...) _snwprintf_s(dst.data(), dst.size(), _TRUNCATE, format..
#include class A {private:public:int a = 5;};std::ostream& operator전역 연산자 오버로딩은 ostream같이 c++표준이라서 구현할 수 없을 때 사용하는 것으로 위와 같이std::ostream& operator그럼 std::cout 그럼 거꾸로 std::ostream& operator #include int main (){ wchar_t sentence [] = L"Michael is 10 years old"; wchar_t str [20]; char str1[20]; int i; swscanf(sentence, L"%ls %*ls %d", str, &i); wprintf (L"%ls -> %d\n",str,i); return 0;}wcha..
https://www.acmicpc.net/problem/1167탐색을 이용한 조금 복잡한 문제를 풀어보았다. #include #include #include using namespace std;static bool print = false;int BFS(vector>>&, int);int main() { int N; cin >> N; vector>> arr(N + 1); for (int i = 1; i > index; while (true) { cin >> node; if (node != -1) { cin >> edge; if (edge != -1) { arr[index].emplace_back(make_pair(node, edge)); } else bre..
https://www.acmicpc.net/problem/2178BFS로 푸는 가장 보편적인 문제인 미로에서 최소거리 탐색문제이다. #include #include #include using namespace std;void BFS(vector>&);int main() { cin.tie(0)->sync_with_stdio(false); int N, M; cin >> N >> M; vector> arr(N + 2, vector(M + 2, 0)); for (int i = 1; i > tmp; for (int j = 1; j >& arr) { queue> q({ make_pair(1,1) }); vector> visit(arr.size(), vector(arr[0].size(), false)); int n..
너비 우선 탐색(breadth-first-search)도 그래프를 완전 탐색하는 방법 중 하나로, 시작 노드에서 출발해 시작 노드를 기준으로 가까운 노드를 먼저 방문하면서 탐색하는 알고리즘이다. 특징으로 Queue 자료구조를 이용하고, 시간 복잡도는 O(V+E) V = 노드 수, E = 엣지 수 이다. 너비 우선 탐색의 핵심 이론 1. BFS를 시작할 노드를 정한 후 사용할 자료구조 초기화하기2. 큐에서 노드를 꺼낸 후 꺼낸 노드의 인접 노드를 다시 큐에 삽입하기3. 큐 자료구조에 값이 없을 때까지 반복하기 방문한 노드는 다시 방문하지 않으므로 방문한 노드를 체크하기 위한 추가적인 배열이 필요하다. https://mngprog.tistory.com/39&);int main() { cin.tie(0)..
https://www.acmicpc.net/problem/13023간단하게 재귀함수로 풀어본 문제이다. #include #include using namespace std;static bool arrive = false;void DFS(const vector>&, int, int);int main() { cin.tie(0)->sync_with_stdio(false); int N, E; cin >> N >> E; vector> arr(N, vector()); int index = 0; for (int i = 0; i > index >> tmp; arr[index].emplace_back(tmp); arr[tmp].emplace_back(index); } for (int i = 0; i >& arr, i..
https://www.acmicpc.net/problem/2023간단하게 재귀함수로 풀 수 있는 문제이다. #include #include #include using namespace std;void DFS(int, int, int);bool isPrime(int);static vector arr;int main() { cin.tie(0)->sync_with_stdio(false); int N; cin >> N; DFS(2, N, 1); DFS(3, N, 1); DFS(5, N, 1); DFS(7, N, 1); for (auto& it : arr) { cout
깊이 우선 탐색(depth first search)은 그래프 완전 탐색 기법 중 하나이다. 깊이 우선 탐색은 그래프의 시작 노드에서 출발하여 탐색할 한쪽 분기를 정하여 최대 깊이까지 탐색을 마친 후 다른 쪽 분기로 이동하여 다시 탐색을 수행하는 알고리즘이다. 깊이 우선 탐색의 특징으로 보통 재귀 함수나 자료구조중에 스택을 이용하여 구현하는데 DFS는 선출후입의 구조를 가지고 있기 때문이다. 시간복잡도는 O(V + E)로 V는 노드의 개수이고, E는 엣지의 개수이다. 재귀 함수를 이용하여 구현하면 스택오버플로우를 유의하며 구현하여야 한다. 깊이 우선 탐색의 핵심 이론 DFS는 한 번 방문한 노드를 다시 방문하면 안 되므로 노드 방문 여부를 체크할 추가적인 배열이 필요하다. https://mngprog...