diff --git "a/\345\256\236\351\252\214\344\270\200/CPP/1817022-\345\256\236\351\252\2141.cpp" "b/\345\256\236\351\252\214\344\270\200/CPP/1817022-\345\256\236\351\252\2141.cpp" new file mode 100644 index 0000000000000000000000000000000000000000..c933c440cb2f2ce6a63ac3a3c65809659a8215ae --- /dev/null +++ "b/\345\256\236\351\252\214\344\270\200/CPP/1817022-\345\256\236\351\252\2141.cpp" @@ -0,0 +1,49 @@ +#include + +using namespace std; + +void Qsort(int arr[], int low, int high) { + if (high <= low) return; + int i = low; + int j = high + 1; + int key = arr[low]; + while (true) + { + while (arr[++i] < key) + { + if (i == high) { + break; + } + } + while (arr[--j] > key) + { + if (j == low) { + break; + } + } + if (i >= j) break; + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + int temp = arr[low]; + arr[low] = arr[j]; + arr[j] = temp; + Qsort(arr, low, j - 1); + Qsort(arr, j + 1, high); +} + +int main() +{ + int a[10]; + for (int + i = 0; i < 10; i++) + { + cin >> a[i]; + } + Qsort(a, 0, sizeof(a) / sizeof(a[0]) - 1); + for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) + { + cout << a[i] << " "; + } +} diff --git "a/\345\256\236\351\252\214\344\270\200/HTML/1817022-1.html" "b/\345\256\236\351\252\214\344\270\200/HTML/1817022-1.html" new file mode 100644 index 0000000000000000000000000000000000000000..3a8e9d044e7748b93ae480cbde46461972153968 --- /dev/null +++ "b/\345\256\236\351\252\214\344\270\200/HTML/1817022-1.html" @@ -0,0 +1,54 @@ + + + + + + Document + + + +
输入:-2,11,-4,13,-5,-2
+
输出:20
+ + \ No newline at end of file diff --git "a/\345\256\236\351\252\214\344\270\200/\345\256\236\351\252\214\346\212\245\345\221\212/1817022-1.doc" "b/\345\256\236\351\252\214\344\270\200/\345\256\236\351\252\214\346\212\245\345\221\212/1817022-1.doc" new file mode 100644 index 0000000000000000000000000000000000000000..18f3d4cd39fabf939c8c6f27ef3efc8973e4115c Binary files /dev/null and "b/\345\256\236\351\252\214\344\270\200/\345\256\236\351\252\214\346\212\245\345\221\212/1817022-1.doc" differ diff --git "a/\345\256\236\351\252\214\344\270\200/\350\256\272\346\226\207\351\252\214\350\257\201\347\250\213\345\272\217/.keep" "b/\345\256\236\351\252\214\344\270\200/\350\256\272\346\226\207\351\252\214\350\257\201\347\250\213\345\272\217/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\256\236\351\252\214\344\270\200/\350\256\272\346\226\207\351\252\214\350\257\201\347\250\213\345\272\217/1817022/.keep" "b/\345\256\236\351\252\214\344\270\200/\350\256\272\346\226\207\351\252\214\350\257\201\347\250\213\345\272\217/1817022/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\256\236\351\252\214\344\270\200/\350\256\272\346\226\207\351\252\214\350\257\201\347\250\213\345\272\217/1817022/1817022-1.cpp" "b/\345\256\236\351\252\214\344\270\200/\350\256\272\346\226\207\351\252\214\350\257\201\347\250\213\345\272\217/1817022/1817022-1.cpp" new file mode 100644 index 0000000000000000000000000000000000000000..21a7bba1321464eebdbb8f6e4f0c3aec980623cb --- /dev/null +++ "b/\345\256\236\351\252\214\344\270\200/\350\256\272\346\226\207\351\252\214\350\257\201\347\250\213\345\272\217/1817022/1817022-1.cpp" @@ -0,0 +1,201 @@ +#include +#include +#include +#include +#include +#define N 10 +using namespace std; +string isright(int *arr,int n) +{ + for(int i=0;iarr[i+1]){ + return "false";break;} + else return "true"; + } +} +//ذ + void quickSort(int *arr,int left,int right) + { + if (left >= right) return; + int le= left; + int ri= right; + int key = arr[left]; + while (le= key) + { + ri--; + } + arr[le] = arr[ri]; + while (le>1);//м± + int midValue=-1;//мֵ± + if(a[p]<=a[midIndex]&&a[p]>=a[r]) midValue=p; + else if(a[r]<=a[midIndex]&&a[r]>=a[p]) midValue=r; + else midValue=midIndex; + swap(a[midValue],a[p]); + + int x=a[p];//׼ + int l=p+1,q=r; + while(l<=q){ + while(a[l]<=x&&l<=q) ++l; + while(a[q]>x&&l<=q) --q; + if(l<=q) swap(a[l],a[q]); + } + swap(a[p],a[q]); + return q; +} +void partition1(int *a,int n) +{ + partition(a,0,n-1); +} + +//ֵ +void insertsort(int a[],int p,int q){// + int temp; + for(int i=p;i<=q;i++){ + if(a[i]=0;j--){ + if(j>0&&a[j-1]>temp) a[j]=a[j-1]; + else { + a[j]=temp; + break; + } + } + } + } +} +int getmid(int a[],int p,int r){ + int length=r-p+1; + int grouplength=(length%5==0)?(length/5):(length/5+1);//ÿԪһ飬õֵĸ + int *medians=new int[grouplength];//洢мֵ + int midIndex=0; + for(int i=0;i +using namespace std; +int dst[5010]; +int n,m; +bool s[5010]; +int pre[5010]; +struct node +{ + int v,w; + node(){} + node(int vv,int ww) + { + v=vv,w=ww; + } +}; +vector g[5010]; +void init() +{ + for(int i=1;i<=5000;i++) + { + dst[i]=0x7f7f7f7f; + } +} +int main() +{ + init(); + int a,b,c; + cin>>n>>m; + for(int i=1;i<=m;i++) + { + cin>>a>>b>>c; + g[a].push_back(node(b,c)); + g[b].push_back(node(a,c)); + } + s[1]=1; + dst[1]=0; + int lasti=1; + for(int k=1;k +#include + +using namespace std; + +#define N 100 + +struct goods{ +int sign;//Ʒ +int wight;//Ʒ +int value;//Ʒֵ +}; + +int n,bestValue,cv,cw,C;//Ʒֵ󣬵ǰֵǰ +int X[N],cx[N];//մ洢״̬ǰ洢״̬ +struct goods goods[N]; + +int Force(int i){ +if(i>n-1){ + if(bestValue < cv && cw + goods[i].wight <= C){ + for(int k=0;k + + + + + + + + 递归 + + + + +
+

递归“0-1背包问题”




+ 输入物品个数
+ 输入物品价值
+
+     +
+ + + + + \ No newline at end of file diff --git "a/\345\256\236\351\252\214\344\272\214/\345\256\236\351\252\214\346\212\245\345\221\212/1817022-2.doc" "b/\345\256\236\351\252\214\344\272\214/\345\256\236\351\252\214\346\212\245\345\221\212/1817022-2.doc" new file mode 100644 index 0000000000000000000000000000000000000000..82546734307f43b45571f6ba43ee16220a25e7aa Binary files /dev/null and "b/\345\256\236\351\252\214\344\272\214/\345\256\236\351\252\214\346\212\245\345\221\212/1817022-2.doc" differ