引用变量在创建的时候就必须初始化。无法创建一个未被初始化的引用。
#include
using namespace std;
int main()
{
int x=10;
int y=20;
int &r1;
}
编译结果:
如果引用未被初始化,编译将报错。
修改引用:
引用总是指向初始化的那个变量,也就是说,引用一旦被创建并初始化之后就无法改变。这一...
分类:
编程语言 时间:
2014-06-22 22:22:59
阅读次数:
215
可以创建任何类型的引用,包括指针类型。
看一个简单的指针的引用的例子。例如:
#include
using namespace std;
int main(){
int x=10;
int y=20;
int z=30;
int* ptx=&x;
int* ptz=&z;
//指针的引用,声明从右往左看,rtp与&结合,
//剩余的符号...
分类:
编程语言 时间:
2014-06-22 21:15:26
阅读次数:
287
#include
#include
#include
using namespace std;
int main()
{
string word;
string line;
while (getline(cin,line))
{
istringstream istr(line);
while(istr>>word)
cout<<wo...
题意:有M,G两人和鬼魂(Z)在n*m的方格内,M每秒走3步,G每秒走一步,鬼魂每秒走2步,问是否能
不遇到鬼魂下两人相遇,鬼魂可以穿墙(X),人不可以。初始鬼魂有2个。
#include
#include
#include
#include
#include
#include
#include
#define M 800
using namespace std...
分类:
Web程序 时间:
2014-06-22 18:57:14
阅读次数:
189
f[i]=f[i-1]*p+f[i-2]*(1-p);
正好可以用矩阵加速。。。。
#include
#include
#include
#include
#include
using namespace std;
struct matr
{
double mat[3][3];
friend matr operator *(const matr a,const matr b)
...
分类:
其他好文 时间:
2014-06-22 18:23:06
阅读次数:
173
我们来看一个简单的指向引用的指针的例子。
#include
using namespace std;
int main(){
int x=10;
int y=20;
int &rtx=x;
//不要写成了int& *ptrx=&rtx;
//因为rtx的本质是一个int
int *ptrx=&rtx;
*ptrx=15;
ptrx...
分类:
编程语言 时间:
2014-06-22 14:41:42
阅读次数:
272
这道题也有点新意,就是需要记录最小值段和最大值段,然后成段更新这个段,而不用没点去更新,达到提高速度的目的。
本题过的人很少,因为大部分都超时了,我严格按照线段树的方法去写,一开始居然也超时。
然后修补了两个地方就过了,具体修改的地方请参看程序。
知道最大值段和最小值段,然后修补一下就能过了。不是特别难的题目。
#include
#include
#include
using na...
分类:
其他好文 时间:
2014-06-21 20:14:04
阅读次数:
230
Is it a dream that you can access text files using SQL statements?
But now, it is true that DB Query Analyzer provides you a power tool which can help you realize the dream above. I’ll give you a sample to show its powerful function. What’s more, the p...
分类:
数据库 时间:
2014-06-21 18:41:54
阅读次数:
510
1 #include "iostream" 2 using namespace std; 3 4 float MAX(float m1,float m2){ 5 if(m1>=m2) 6 return m1; 7 else 8 return m2;...
分类:
其他好文 时间:
2014-06-21 16:05:31
阅读次数:
205
Creating an IP Tunnel using GRE on Linux Contents[hide] · 1 IP Tunelling · 2 Starting Configuration · 3 Tunnelling Objective ...
分类:
系统相关 时间:
2014-06-21 15:27:26
阅读次数:
598