算法
文章平均质量分 90
Leetto_
这个作者很懒,什么都没留下…
展开
-
Knapsack Problem(背包问题)
#include <bits/stdc++.h>using namespace std;int w[4]={2, 1, 3, 2};int v[4]={3, 2, 4, 2};int n=4, W=5;// Recursion algorithmint REC(int num, int rem){ int res; if(num == n) res = 0; else if(rem < w[num]) res = REC(num + 1, rem原创 2020-11-21 11:38:30 · 204 阅读 · 0 评论 -
四种排序算法(冒泡排序、选择排序、归并排序、快速排序)的实现
本文用C++实现了四种基础的排序算法,冒泡排序、选择排序、归并排序、快速排序#include <bits/stdc++.h>using namespace std;void Swap(int* a, int* b){ int temp; temp = *a; *a = *b; *b = temp; return;}void BubbleSort(int num[], int len, bool flag){ int temp=0原创 2020-11-13 22:57:14 · 421 阅读 · 0 评论