목록CS/Data Struct (9)
프로그래밍 공부
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include using namespace std; #define SWAP(type,x,y) {type t = x; x = y; y = t;} void selection_sort(int *arr, int n){ int i, j; for(int i = 0; i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #include using namespace std; #define SWAP(x,y){ x ^= y ^= x ^= y; } void bubble_sort(int *arr, int n){ for(int i = 0; i i; j--){ if(arr[j-1] > arr[j]){ SWAP(arr[j-1],arr[j]); } } } } int main() { int arr[5] = {3,2,5,9,1}; for(auto i : arr){ cout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 #include #include #include #include using namespace std; string compress(string bf) { string af; int count = 0, pre = 0; while (bf.size() != count) { int cnt = 0; char ch = bf[pre]; ..