const在函数中也有很大的作用。
4.const修饰传入参数。
函数传入参数声明为const,以指明使用这种参数仅仅是为了效率的原因,而不是想让调用函数能够修改该传入参数的值。同理,将对象指针参数或引用参数声明为const,函数将不修改由这个参数所指的对象。
例如:
#include
using namespace std;
//void change(const i...
分类:
编程语言 时间:
2014-05-26 05:52:27
阅读次数:
266
A Matrix
题意:按照题目中给定的方法,给你一个矩阵,求出变换出该矩阵的字符串
思路:构造问题,在纸上多画几组就能发现,每次必须从上往下找到一条路径,最后输出这些路径,按照开头最大的最晚输出,找的过程中只要不断往下一层找一个大的即可,并且如果一开使有一行是非递增就是错误
代码:
#include
#include
#include
#include
using names...
分类:
其他好文 时间:
2014-05-26 05:24:51
阅读次数:
220
Beautiful Garden
题意:x轴上放了一些树,现在要移动一些树使得所有树都等间距,问最少要移动多少棵
思路:枚举,枚举第一棵树,和另一棵树,以及中间有多少树,这样就能知道等差数列的首项和公差,然后再循环一边计算出答案,保存最小值
代码:
#include
#include
#include
#include
using namespace std;
#define...
分类:
其他好文 时间:
2014-05-26 04:28:52
阅读次数:
233
Several ports(8080,8009)required by Tomcat v6.0 Server at localhost are already in use.The server may already be running in another process, or a system process may be using the port, To start this server you will need to stop the other process or change t...
分类:
编程语言 时间:
2014-05-26 03:41:22
阅读次数:
364
Point.h
/*
* Point.h
*
* Created on: 2014年5月22日
* Author: John
*/
#include
using namespace std;
#ifndef POINT_H_
#define POINT_H_
class Point {
private:
int x;
int y;
...
分类:
编程语言 时间:
2014-05-26 03:19:07
阅读次数:
399
简单数论题。区间减法。 1 //Accepted 0 KB 9 ms 2 #include 3
#include 4 using namespace std; 5 const int MAXN = 100005; 6 int f[MAXN]; 7 void
pre() 8 { 9 ...
分类:
其他好文 时间:
2014-05-26 02:54:57
阅读次数:
278
1 #include 2 using namespace std; 3 //#define
maxSize 20 4 template 5 class Queue 6 { 7 private : 8 // T data[maxSize]; 9 int
maxSize;10 ...
分类:
其他好文 时间:
2014-05-26 02:50:09
阅读次数:
267
A:list总时间限制:4000ms内存限制:65536kB描写叙述写一个程序完毕下面命令:new
id ——新建一个指定编号为id的序列(id#include #include #include using namespace std;typedef map
> Map;int main(){ i...
分类:
其他好文 时间:
2014-05-26 02:26:51
阅读次数:
337
题意:经典八数码问题
思路:HASH+BFS#include
#include
#include
#include
using namespace std;
const int MAXN = 500000;
const int size = 1000003;
typedef int State[9];
char str[30];
int state[9],goal[9]={1, 2, ...
分类:
其他好文 时间:
2014-05-24 21:46:23
阅读次数:
359
题目:http://poj.org/problem?id=2104
划分树待我好好理解下再写个教程吧,觉得网上的内容一般,,,
模板题:
贴代码:
#include
#include
#include
#include
using namespace std;
#define CLR(a) memset(a,0,sizeof(a))
const int MAXN = 100010...
分类:
其他好文 时间:
2014-05-24 18:10:18
阅读次数:
276