C/C++
API磨练者
这个作者很懒,什么都没留下…
展开
-
C/C++产生区间随机整数或小数的方法
C/C++产生区间随机整数或小数的方法#include <iostream>#include <queue>#include <cstdlib>#include <ctime>const int MIN = 0;const int MAX = 99;using namespace std;int main(){ //prior...原创 2019-03-19 21:01:57 · 1810 阅读 · 0 评论 -
C/C++二维数组各种传参方法
C++二维数组各种传参各种浪#include <stdio.h> #include <iostream> const int M=5; const int N=5; using namespace std; void array_init_v1(int A[][N]) { int i,j,count=0; for(i=0;...原创 2019-03-18 22:48:44 · 364 阅读 · 2 评论 -
求N个数的最大公约数和最小公倍数
求N个数的最大公约数和最小公倍数#include <iostream>#include <cmath>using namespace std;//[15,40] [40,15] [15 10] [10 5] [5 0]//求两个数的最大公约数int gcd(int a,int b){ if(b==0) { return a; } else { ...原创 2019-03-23 01:02:51 · 442 阅读 · 0 评论 -
从n个数中选出k个数
从n个数中选出k个数#include <iostream>#include <vector>#include <algorithm>using namespace std;vector<int> a;vector<int> b;void fun(int a){ cout << a << " ";...原创 2019-03-23 10:07:46 · 2605 阅读 · 0 评论 -
哈夫曼编码C语言
哈夫曼树#include <stdio.h>//哈夫曼树节点个数为2n-1//n为叶子节点的个数//故MAX_NODE>2n-1#define MAX_NODE 200 #define MAX_SIZE 40#define INF 32767//哈夫曼树的数据结构typedef struct{ //权重 float weight ;...原创 2019-03-23 15:58:35 · 507 阅读 · 0 评论 -
动态规划完全背包
动态规划多重背包#include <iostream>using namespace std;int n=3;int w[]={3,4,2};int v[]={4,5,3};int W=7;//f是指标函数//s是状态变量//k是阶段变量int f(int s,int k){ if(s<=0||k>n) return 0; else if(s&...原创 2019-03-23 21:20:31 · 331 阅读 · 0 评论 -
最小二乘法直线拟合的C语言及matlab实现
最小二乘法的简单C语言实现这里直接上代码,理论推导参看普通最小二乘法的推导证明#include <stdio.h>//最小二乘法求散点拟合函数y=a+bx的参数a和bvoid LFM(double x[],double y[],int n){ int i; double a=0,b=0; double sum1=0,sum2=0; double mean_x=0,me...原创 2019-05-21 09:39:41 · 2422 阅读 · 0 评论