Skip to content

Instantly share code, notes, and snippets.

View fpdjsns's full-sized avatar
😄
인생의 풍류를 즐기는 중

withham fpdjsns

😄
인생의 풍류를 즐기는 중
View GitHub Profile
@fpdjsns
fpdjsns / tree traversal.cc
Last active February 10, 2017 04:35
Creates a binary tree with seven nodes. Three ways to travel tree. (preorder, inorder, postorder)
#include<stdio.h>
#include<stdlib.h>
#define node_num 7
//node struct
typedef struct node
{
char alphabet; //alphabet
struct node* left; //left child node
struct node* right; //right child node
#include<stdio.h>
#include<stdlib.h>
#define node_num 26
//node struct
typedef struct node
{
char alphabet; //alphabet
struct node* left; //left child node
struct node* right; //right child node
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)
//이진검색트리노드
typedef struct treenode {
int data;
struct treenode* left;
struct treenode* right;
}treenode;
@fpdjsns
fpdjsns / c++_stl_map.cc
Created February 15, 2017 15:02
How to use map and what effect it is.
#include<iostream>
#include<map>
#include<functional>
using namespace std;
//print map element
void print(map<int, char> m)
{
//empth function
@fpdjsns
fpdjsns / Bubble_Sort.cc
Last active December 17, 2021 05:06
Bubble_Sort. [Input : The first line contains an integer, n, denoting the number of an array size. next line contains n space-separated integers the array data.(like 4 5 3 6 7 2 1)] [output: Print n space-separated integers the sorted array data.]
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//swap
void swap(int &a, int &b)
{
int temp;
@fpdjsns
fpdjsns / two-dimensional array.cc
Created February 24, 2017 04:59
row major ordering & column major ordering
#include<iostream>
#define MAX 100
using namespace std;
//make row major ordering
int (*make_row_major(int a, int b))[MAX]
{
int arr[MAX][MAX] = { 0 };
int temp = 1;
@fpdjsns
fpdjsns / DFS(Depth_First_Search).cc
Last active March 2, 2017 08:02
DFS(Depth First Search). [Input : The first line contains an integer, N(number of vertex), M(number of edge), V(start vertex number). The M line subsequent lines contains two space-separated integers, u and v, defining an connected edge between nodes u and v] [output: Print N space-separated integers the DFS path.]
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
int graph[1001][1001]; //Graph
//N : Number of vertex
//M : Number of edge
//V : Start vertex number
@fpdjsns
fpdjsns / BFS(Breadth_First_Search).cc
Created March 2, 2017 08:05
BFS(Breadth First Search). [Input : The first line contains an integer, N(number of vertex), M(number of edge), V(start vertex number). The M line subsequent lines contains two space-separated integers, u and v, defining an connected edge between nodes u and v] [output: Print N space-separated integers the BFS path.]
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int graph[1001][1001]; //Graph
//N : Number of vertex
//M : Number of edge
//V : Start vertex number
#include<iostream>
using namespace std;
int main() {
int A[21][301] = { 0 }; //A[i][j] : 기업 i가 j금액을 투자했을 때 얻는 이익
int DP[21][301] = { 0 }; //D[i][j] : j금액을 i까지의 기업들이 투자했을 때 얻는 최대 이익
int path[21][301] = { 0 };
int path_money[21] = { 0 };
int money, num;//투자 금액, 기업 갯수
@fpdjsns
fpdjsns / LDS.cc
Last active July 30, 2023 06:30
LDS(Longest Decreasing Sequence). 최장 감소 수열
#include<iostream>
using namespace std;
int main()
{
int n; //입력하는 데이터 갯수
int ind = 0; //d 인덱스
int arr[1000] = { 0 };
int d[1000] = { 0 };