变长一维数组 这里说的变长数组是指在编译时不能确定数组长度,程序在运行时需要动态分配内存空间的数组。实现变长数组最简单的是变长一维数组,你可以这样做: #includeiostream using namespace std; int main() { int len; cinlen; //用指针p指向new动态分配的长度为len*sizeof(int)的内存空间 int *p=new int ; ........... delete ;这一句,你不能这样做: int p ; C++编译器会报错说len的大小不能确定,因为用这种形式声明数组,数组的大小需要在编译时确定。而且这样也不行: int p ;编译器会说不能把int*型转化为int ; 以上程序实现了一个变长的一维数组,但是要养成一个好习惯,就是注意要注销指针p,使程序释放用new开辟的内存空间。 当然使用C++标准模版库(STL)中的vector(向量)也可以实现变长数组: #includeiostream #includevector using namespace std; int main() { int len; cinlen; vectorint array(len);//声明变长数组 for(int i=0;ilen;i++) { array =i; coutarray \t; } return 0; } 2.变长二维数组 用C++实现变长二维数组时可以采用两种方法:双指针方法和使用STL中vector(向量)的方法。 首先介绍一下双指针方法,在这里双指针就是指像指针的指针,比如你可以这样声明一个数组: int **p = new int* ; 而对每一个*p(一共num1个*p)申请一组内存空间: for(int i=0; inum1; ++i) p = new int ; 其中,num1是行数,num2是数组的列数。测试的源程序如下: #include iostream #include iomanip using namespace std; int main() { int num1;//行数 int num2;//列数 coutPlease enter the number for row and column: endl; cin num1 num2; //为二维数组开辟空间 int **p; p= new int* ; for(int i=0; inum1; ++i) p = new int ; for(int j=0;jnum1;j++) { for(int k=0;knum2;k++) { p =(j+1)*(k+1); coutsetw(6)p ':'setw(8)p ; } coutendl; } //释放二维数组占用的空间 for(int m=0;mnum1;m++) delete ; delete = i*j; for (i = 0; i m; i++) { for (j = 0; j n; j++) coutsetw(5)vecInt :setw(9)vecInt ; coutendl; } return 0; } 3.变长三维数组 根据以上一、二维数组,可以推出三维数组的实现。以下是指针实现代码: #include iostream using namespace std; void main() { int ***p3; intx=3,y=2,z=2; p3=new int ** ; for (i=0;ix;i++) { p3 =new int* ; for (int j=0;jy;j++) { p3 =new int ; for (int k=0;kz;k++) { p3 =i*j*k; } } } for (int k=0;kz;k++) { for (int i=0;ix;i++) { for (int j=0;jy;j++) coutp3 ; coutendl; } coutendl; } for (int i=0;ix;i++) { for (int j=0;jy;j++) { delete ; } delete ; } delete =4; coutv endl; } 4.用一维动态数组表示二维、三维动态数组 以下是程序代码: #include iostream using namespace std; void main() { int m=3,n=4,l=2; int *p2; //将表示二维数组 p2=new int ; int i,j,k; for (i=0;im;i++) for(j=0;jn;j++) { p2 =i+j; } cout二维数组endl; for (i=0;im;i++) { for(j=0;jn;j++) { coutp2 ; } coutendl; } delete ; for (k=0;kl;k++) for (i=0;im;i++) for (j=0;jn;j++) { p3 =i+j+k; } cout三维数组endl; for (int k=0;kl;k++) { for (int i=0;im;i++) { for (int j=0;jn;j++) coutp3 ; coutendl; } coutendl; } delete []p3; } 自:http://blog.sina.com.cn/s/blog_436fe8b10100dkzd.html
碳,作为一种非常常见的元素,对有机物有着重要的意义。单质碳材料有零维,一维,二维和三维。这里主要介绍一下富勒烯,碳纳米管和石墨烯这三种材料。 富勒烯(巴基球,足球烯,Fullerene,C60): 作为零维材料,在1985年英国H. W. Kroto和美国R. E. Smalley等人在氦气流中以激光汽化蒸发石墨实验中发现C60。由五元环、六元环等构成的封闭式空心球形或椭球形结构的共轭烯。 1985年文章 C60 Buckminsterfullerene 。 在碳纳米管发现之前,它是研究的热点,在生物和医学有着重要的意义。此外还有C78、C82、C84、C90、C96等。 碳纳米管(carbon naotubes) 作为一维纳米材料,自1991年被S. Iijima发现以来一直是研究的热点。根据层数可分为单壁(single-wall carbon nanotubes)和多壁(multiwall carbon nanotubes)。根据手性可分为非手性(armchair和zigzag)和手性(chiral)结构。中空结构,一般可认为是单层石墨卷曲而成。它在很多领域都有着广泛的应用和前景。正如美国Alex Zettl 教授说,就应用前景对C60和碳纳米管进行全面的比较,C60可以用一页纸概括,而碳纳米管需要一本书来完成。推荐一本书Physical properties of carbon nanotubes(R. Saito, G. Dresselhaus, and M.S. Dresselhaus 1998,Imperial College Press ,世图有卖:39元)。 The field of nanotubes is still rapidly growing. As emphasized, many questions are still unanswered. The dynamics of hot electrons (and electron-hole pairs) in optical experiments, the nature of the contact resistance at metallic electrode interfaces, the effect of an out-of- equilibrium phonon distribution on inelastic scattering, and the domain of existence of the Luttinger-liquid, charge-density-wave, and superconducting phases are still subjects which require a considerable amount of work and understanding. Further, and beyond the intrinsic properties of nanotubes, the physics of functionalized, chemisorbed, doped, or excited CNTs is driven by potential applications in molecular electronics, optoelectronics, and sensors. Such themes are still largely unexplored areas for theorists: while early theoretical papers preceded experiments on the discussion of the basic electronic properties of pristine tubes, such complex systems and applications have now been demonstrated experimentally and theory is lagging behind. The field of nanotubes has fostered much interest in related systems such as graphene or semiconducting nanowires.(摘自Rev. Mod. Phys., Vol. 79, No. 2,667-732,2007.见下面RMP文章). Iijima91年Natrue文章 07年RMP综述文章 Electronic and transport properties of nanotubes 石墨烯(单层石墨,graphene) 作为二维材料,一般厚度方向为单原子层或双原子层碳原子。完美的石墨烯包括六角元胞(等角六边形)。2004年被英国A.K.Geim发现。石墨烯有众多优异的物理性质,在很多现象中有很多异常的行为如整数量子霍尔效应,准粒子激发谱可用2+1维无质量的相对论Dirac方程描述等等。近几年研究的特别热。 Graphene is a unique system in many ways. It is truly 2D, has unusual electronic excitations described in terms of Dirac fermions that move in a curved space, is an interesting mix of a semiconductor (zero density of states) and a metal (gaplessness), and has properties of soft matter. The electrons in graphene seem to be almost insensitive to disorder and electron-electron interactions and have very long mean free paths. Hence, graphene's properties are different from what is found in usual metals and semiconductors. Graphene has also a robust but flexible structure with unusual phonon modes that do not exist in ordinary 3D solids. In some sense, grapheme brings together issues in quantum gravity and particle physics, and also from soft and hard condensed matter. Interestingly enough, these properties can be easily modified with the application of electric and magnetic fields, addition of layers, control of its geometry, and chemical doping. Moreover, graphene can be directly and relatively easily probed by various scanning probe techniques from mesoscopic down to atomic scales, because it is not buried inside a 3D structure. This makes graphene one of the most versatile systems in condensed-matter research。(摘自Rev. Mod. Phys., Vol. 81,No. 1,109-162,2009.文章见下面). 09年RMP综述文章 The electronic properties of graphene