반응형 [알고리즘 + 자료구조]/[백준]214 [BaekJoon/백준] 2750번 Bubble Sort와 Insert Sort를 각각 이용해서 문제 해결 #include using namespace std; void Bubble_sort(int* arr, int N) { int temp; for(int i = N-1; i>0; i--) { for(int j = 0; jarr[j+1]) { temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } } void insert_sort(int* arr, int N) { for(int i=1; i N; int* arr = new int[N]; for(int i=0; i> arr[i]; } insert_sort(arr, N); //or Bubble_sort(arr, N); for(int i=0; i 2020. 10. 5. [BaekJoon/백준] 1436번 아..빡친다. 문제 똑바로 안읽고 풀었다가 혼자 존재하지도 않는 문제로 풀면서 "코드에 틀린게 정말 하나도없는데 왜틀렸다는걸까" 하면서 절망했다. 연속 상관없이 6이 세번 들어가면 되는걸로 생각하고 문제를 풀었다. ㅋㅋ 그리고 왜 답이 계속 틀렸다는 건지 애꿎은 코드만 계속 바라보고 바라보고,,, 테스트해보고.. 지랄을했다. 코드가 아까우니..올려라도 본다.. 이건 '6이 적어도 세번 들어가는 수'의 경우에 대한 코드다. 연속이건 아니건 상관없이 말이다. public class triple { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); long N = scanner.nextLong(); long co.. 2020. 10. 3. [BaekJoon/백준] 1018번 이 문제는 좀 재밌었다. 문제 이해가 안돼서 힘들었던 거 빼고 ㅋㅋ.. import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int N, M; static boolean[][] arr, arr_copy; static int count=0, key=2500; // count를 재활용하고, key에 저장하여 사용. public static void main(String args[]) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in.. 2020. 10. 3. [BaekJoon/백준] 7568번 import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int[][] arr = new int[N][3]; // 3번째 인덱스에 덩치 순서값 저장 for(int i=0; i 2020. 10. 2. 이전 1 ··· 42 43 44 45 46 47 48 ··· 54 다음 반응형