随笔分类 - c++
摘要:1 #include 2 using namespace std; 3 4 typedef struct TBTNode 5 { 6 char data; 7 int ltag,rtag; 8 struct TBTNode * lchild; 9 ...
阅读全文
摘要:#include #define maxSize 5using namespace std;typedef struct BTNode{ char data; struct BTNode * lchild; struct BTNode * rchild;}BTNode;BTNode...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 typedef struct BTNode 5 { 6 char data; 7 struct BTNode * lchild; 8 struct BTNode * rchild; 9 }BTN...
阅读全文
摘要:列出n以内的质子数 1 #include 2 #include 3 using namespace std; 4 5 int* Sieve(int n, int &length) 6 { 7 int *A,*B; 8 int p=0,j=0,i=0,k=0,q=0; 9 ...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 int gcd(int m , int n) 5 { 6 int r; 7 while(n!=0) 8 { 9 r = m%n;10 m = n;11 ...
阅读全文
摘要:1 #include 2 #define MAXSIZE 50 3 #define QUEUEELEMENTTYPE int 4 using namespace std; 5 6 struct SeqQueue 7 { 8 QUEUEELEMENTTYPE element[MAXSIZ...
阅读全文
摘要:1 #include 2 #define QUEUEELEMENTTYPE int 3 using namespace std; 4 5 /*结点*/ 6 typedef struct Node 7 { 8 QUEUEELEMENTTYPE data; /*数据域*/ ...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 struct Node 5 { 6 int data; 7 Node *next; 8 }; 9 10 /*初始化链栈*/11 void InitChainStack(Node *top)12 {13 ...
阅读全文
摘要:1 #include 2 #define STACKSIZE 50/*设栈中元素个数为50个*/ 3 using namespace std; 4 5 struct SeqStack 6 { 7 int elem[STACKSIZE]; 8 int top; ...
阅读全文
摘要:LinearList.cpp 1 /* 2 458043535@qq.com 3 xxdfly 4 */ 5 #include "LinearList.h" 6 7 //构造函数 8 LinearList::LinearList() 9 { 10 head...
阅读全文
摘要:这俩天重新学习数据结构,参考书使用C描述的,由于以前一直用JAVA,C已经生疏了好多,指针那块很不扎实,深深感受着来自面向对象与面向过程的碰撞,用惯java习惯性的就会以面向对象的思想去考虑编程以及问题,时间久了真的有点忘了C的模样,再次接触面向过程的编程,感觉有时候会很方便,但总感觉有点混乱,按过...
阅读全文
摘要:1 #include 2 3 using namespace std; 4 5 struct Node{ 6 int data; 7 Node *next; 8 }; 9 10 Node* InitNodeList(){11 Node *node=0;//定义一个空指...
阅读全文
摘要:类的定义class 类名{ private: 私有成员 protected: 保护成员 public: 公有成员}成员函数可以在类内定义,也可以在类外定义。便以系统对类内定义的成员函数是作为内联函数处理的,因此,对较为简短的成员函数,常在类内定义。成员函数也可以值写出函数原型...
阅读全文
摘要:被调用的函数理应定义在前,调用在后。如果被调用的函数是在后面定义的,此时就需要先声明一个函数原型在前面,这样也就可以进行调用了。函数原型必须表明 函数的类型,函数名,形式参数表,函数原型末尾要加一个分号形式如下: 函数类型 函数名(形式参数表); 1 #include 2 using name...
阅读全文
摘要:1 int main(int argc, char* argv[])2 {3 int c=5;4 int *a=&c;5 int *b;6 b=&c;7 return 0;8 }指针声明指针类型* 指针实例名*a 就是指针a所指地址上的数据a 就是该指针所指的...
阅读全文
摘要:定义结构体:struct 结构体名{ ... 结构体数据};定义结构体实例:结构体名 结构体实例名;在使用结构体实例调用其内部的成员变量时,使用运算符 "." 进行。若定义的结构体实例为指针形式,则应该使用运算符 -> 进行成员变量的调用。 1 #include 2 using namespa...
阅读全文
摘要:iostream.h为非标准的输入输出流,这个.h的头文件是C语言格式的,由于当时还没有命名空间这个说法,所以也就不存在std这个名字空间标识符。自然用iostream.h也就用不着std或using namaspce std了。iostream为标准输入输出流,它是c++规范的带有名称空间的头文件...
阅读全文