목록분류 전체보기 (159)
할껀하고놀자
#include #include #include using namespace std; const int n = 7; const int m = 11; int getParent(int parent[], int x) { if (x == parent[x]) return x; return parent[x] = getParent(parent, parent[x]); } void unionParent(int parent[], int a, int b) { a = getParent(parent, a); b = getParent(parent, b); if (a < b)parent[b] = a; else parent[a] = b; } int find(int parent[], int a, int b) { a = getParen..
#include using namespace std; int getParent(int parent[], int x) { if (parent[x] == x) return x; return parent[x] = getParent(parent, parent[x]); } // 각 부모노드를 합친다. void unionParent(int parent[], int a, int b) { a = getParent(parent, a); b = getParent(parent, b); if (a < b) { parent[b] = a; } else { parent[a] = b; } } int findParent(int parent[], int a, int b) { a = getParent(parent, a); b = getP..
#include #include using namespace std; int number = 7; int c[8]; vector a[8]; void dfs(int x) { if (c[x]) return; c[x] = true; cout
#include #include #include using namespace std; int number = 7; int c[7]; vector a[8]; void bfs(int start) { queue q; q.push(start);// 첫번째꺼 넣어주고 c[start] = true;// 방문처리 해주기. while (!q.empty()) {// 큐가 빌때가지 돌려주기. int x = q.front();// 하나 뽑아준다. q.pop(); cout
#include #include using namespace std; int main(){ queue q; q.push(7); q.push(5); q.push(4); q.pop(); q.push(6); q.pop(); while (!q.empty()) { cout
#include #include using namespace std; int main(){ stack st; st.push(7); st.push(5); st.push(4); st.pop(); st.push(6); st.pop(); while (!st.empty()) { cout
#include #include #include using namespace std; class Student { public: string name; int score; Student(string name, int score) { this->name = name; this->score = score; } // 정렬 기준은 '점수가 작은 순서' bool operator score < student.score; } }; int main(void) { Student students[] = { Student("유동관", 90), Student("김범현", 93), Student("권오현", 97), Student("강종구", 87), Student("이태일", 92) }; sort(students, stude..
#include #include #include using namespace std; void quick_sort(int * data, int start, int end) { if (start >= end) { return;// 원소가 1개인 경우. } int pivot = start; int i = pivot + 1; int j = end; int tmp; while (i j) { tmp = data[j]; data[j] = data[pivot]; data[pivot] = tmp; } else { tmp = data[i]; data[i] = data[j]; data[j] = tmp; } for (int i = 0; i < 10; i++) { cout
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static int [] dy = {0,0,1,-1}; static int [] dx = {1,-1,0,0}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int [][] a = new int [n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i]..
import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static int [] dy = {0,0,1,-1}; static int [] dx = {1,-1,0,0}; static Shark bfs(int [][]a,int sy,int sx,int size) { int n = a.length; ArrayList arr = new ArrayList(); int [][] d = new int [n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { d[i][j] = -1; } ..