Skip to content

Instantly share code, notes, and snippets.

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

withham fpdjsns

😄
인생의 풍류를 즐기는 중
View GitHub Profile
@fpdjsns
fpdjsns / Quick_Sort(Recursive).cc
Last active October 13, 2016 07:19
학생 정보(학번, 이름, 성적)을 입력받아 성적 순 학번 순으로 퀵정렬
#include<stdio.h>
#include<string.h>
#pragma warning(disable:4996)
#define MAX 100
typedef struct student
{
int hakbun; //학번
char name[40]; //이름
#include<stdio.h>
#define MAX 100
typedef struct{
int left; //하한
int right; //상한
}element; //스택 구조체
element stack[MAX];
int top = -1; //스택 top=-1
@fpdjsns
fpdjsns / Sum_in_a_row.cc
Created October 27, 2016 05:24
연속합 구하기
#include<iostream>
using namespace std;
int main()
{
int N;//정수 갯수
int arr;
int now_sum, max_sum;
int max_num;//입력 받은 수 중 최대 수
@fpdjsns
fpdjsns / Pair_descending_order.cc
Last active October 28, 2016 13:42
pair descending order using sort function.
#include<iostream>
#include<algorithm>
using namespace std;
bool compare(const pair<int, int>& a, const pair<int, int>& b)
{
//If the first number is same
if (a.first == b.first)
return a.second > b.second; //The second number in Descending order
@fpdjsns
fpdjsns / 유리수의 사칙연산(Rational number Four fundamental rules of arithmetics).cc
Last active February 7, 2017 05:34
유리수의 사칙연산(Rational number Four fundamental rules of arithmetics)(add, subtraction, multiplication, division
#include<iostream>
using namespace std;
typedef struct _Rational {
int bunZa, bunMo;
} Rational;
//Greatest common divisior(최대공약수)
int GCD(int a, int b)
@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
@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
@fpdjsns
fpdjsns / CC(Coin_Change).cc
Last active March 8, 2017 10:33
CC(Coin Change) 동전 교환
#include<iostream>
using namespace std;
int main()
{
int n, money, cost;
int d[11][1000] = { 0 };
cin >> n >> money;
d[0][0] = 1;