- 博客(4)
- 收藏
- 关注
原创 背包问题+路径记录
#define _CRT_SECURE_NO_WARNINGS 1#include<iostream>#include<algorithm>#include<cstring>using namespace std;int a[21];int q[21];bool f[21][100001];//记录选择的物品int main(){ freopen("input.txt", "r", stdin); int n; while ((...
2022-02-07 11:39:34
513
原创 new的应用
一维数组int *p=new int[n];//n为数组大小二维数组int **p=new int*[m] ;//创建int p[m][n];for(int i=0;i<m;i++){p[i]=new int [n];}初始化不可以直接memset(p,0,sizeof(p));动态数组分配的内存不一定连续应该为for(int i=0;i<n;i++){memset(&p[i],0,sizeof(int));}...
2022-01-27 13:56:49
221
原创 dfs(第一次成功代码)(全排列)
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>int n;int used[10] = { 0 };int a[10] = { 0 };void printf_() { for (int i = 1; i <= n; i++) printf("%d", a[i]); printf("\n");}void dfs(int k) { if (k == n + 1) { ...
2022-01-19 16:05:51
566
原创 浮点数比较(范围比较)
#define eps 1e-8int sgn(double a){return a<-eps?-1:a>eps?1:0;}浮点数A,BA>B sgn(A-B)>0A=B sgn(A-B)==0A<B sgn(A-B)<0
2022-01-15 17:38:10
202
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅