自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 资源 (2)
  • 收藏
  • 关注

原创 动态规划0-1背包

#include#includeusing namespace std;//0-1背包问题,n种物品和一背包,物体i的重量是w[i],其价值为v[i],背包容量c。//m(i,j)是背包容量为j,可选物品为1,...,i时的背包问题的最优值,用m[][]来存储m(i,j)的相应值 ,m[n+1][c+1]//templatevoid Knapsack(int v[],int

2012-05-29 21:33:49 256

转载 c 语言 二维数组的函数参数传递的问题

二维数组的函数参数传递的问题,以前解决过好几次,总还是忘记,这回总结出来写在这里。#include void print_a(int a[][5], int n, int m) {int i, j;for(i = 0; i {for(j = 0; j printf("%d ", a[i][j]);printf("\n");}}vo

2012-05-29 15:15:50 303

原创 n后问题

// nQueen.cpp : 定义控制台应用程序的入口点。#include "stdafx.h"#include using namespace std;class Queen{ friend int nQueen();public: bool Place(int k); void Backtrack(void); int n;//皇后的个数 int

2012-05-27 21:46:52 291

原创 资源分配动态规划

// ResourceAlloc.cpp : 定义控制台应用程序的入口点。////#include "stdafx.h"#include using namespace std;//输入:资源份额m,工程数n,各个工程对应的利润函数表p[n][m+1];//f[n][m+1]记录前i个工程分配到不同份额资源时可获得的最大利润;数组d[n][m+1]记录f[i][x]最大时,

2012-05-27 21:25:41 923

原创 最大子段和问题的分治实现和动态实现

//最大子段和问题的分治算法int MaxSubSum(int *a,int left,int right){ int sum=0; if (left==right) sum=a[left]>0?a[left]:0; else {  int center=(left+right)/2;  int leftsum=MaxSubSum(a,left,center);

2012-04-19 21:22:12 320

原创 动态规划 最长公共子序列

//头文件//LCSLength//X[] 为X序列  Y[] 为Y序列//c[i][j]存储Xi,Yj的最长公共子序列的长度//b[i][j]记录c[i][j]的值是由哪一个子问题的截得到的//c[i][j]= | 0;    (i=0,j=0;)//c[i][j]= | c[i-1][j-1]; (x[i]=y[j])  b[i][j]=1//c[i][j]= |

2012-04-19 19:13:01 226

原创 贪心算法最短路径

//头文件#include const int maxint=101;template void Dijkstra(int n,int v,Type dist[],int prev[],Type (&c)[x][y]){//单源最短路径的Dijkstra算法 bool s[maxint]; for (int i=1;i {  dist[i]=c[v][i];

2012-04-17 19:57:01 627

转载 size_type 和 size_t 的区别

先是看到了在看标准库string时size_type,后来在学习标准库bitset的时候有碰到了size_t,晕啊先说说是在什么样的机缘巧合下与size_type相遇的吧,O(∩_∩)O标准库string里面有个函数size,用来返回字符串中的字符个数,具体用法如下:string st("The expense of spiritn");cout 那么size()这个函数返

2012-04-15 20:37:31 359

转载 收集的关于C++中CString,int,string,char*,string之间的转换

string 转 CString CString.format("%s", string.c_str()); char 转 CString CString.format("%s", char*); char 转 string string s(char *); string 转 char * char *p = string.c_str(); str

2012-04-15 18:11:49 343

原创 哈希排序

#include "stdafx.h"#includeusing namespace std;typedef struct HashNode{ int data; HashNode *next;} *HashList;//散列链表的每个结点的数据结构 inline void swap(int &i,int &j){ int temp=i; i=j;

2012-04-01 01:30:17 2412

原创 哈希查找

// HSearch.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include#define MAXSIZE 5 //#define 后面不加;他妹的我竟然忘了 using namespace std;typedef struct HashNode{ int data; HashNode *next;} *HashL

2012-03-21 00:27:12 322

原创 c++ 数组参数小研究

#includeusing namespace std;void process_2d(int *a, int n, int m){      for (int i = 0; i             for (int j = 0; j                   a[i*m+j] = 0;}templateinline void process(in

2012-03-19 13:13:30 211

转载 MYSQL常用命令

MYSQL常用命令1.导出整个数据库mysqldump -u 用户名 -p --default-character-set=latin1 数据库名 > 导出的文件名(数据库默认编码是latin1)mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql2.导出一个表mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名

2012-03-17 10:58:46 168

原创 二分查找

#include using namespace std;template T bSearch(T a[],int n,T s){ int mid; int left=0; int right=n-1; while (left {  mid=(left+right)/2;  if (a[mid]==s)  {   return mid;  }

2012-03-16 12:24:04 186

原创 合并排序

#include using namespace std;template void Merge(T B[],T C[],T A[],int m,int n){ int i=0,j=0,k=0; while (i {  if (B[i]  {   A[k++]=B[i++];  }  else  {   A[k++]=C[j++];  }

2012-03-16 12:20:47 193

原创 快速排序

#includeusing namespace std;int Partition(int A[], int l, int h){ int low=l,high=h;  int pivotkey = A[l]; while (low  {  while (A[high] >= pivotkey&&high>l)   --high;  A[low] = A[h

2012-03-16 11:41:25 205

数据结构与算法分析(C语言).

数据结构与算法分析(C语言),写得非常好,可供学习借鉴好使用

2012-04-20

牛津实用英语语法.chm

牛津实用英语语法.chm ,学语法必备。牛津实用英语语法.chm ,学语法必备。牛津实用英语语法.chm ,学语法必备。牛津实用英语语法.chm ,学语法必备。

2012-03-16

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除