C
HolyCode_
大厂架构 | 代码摄手 | BUG 猎人
分享生活工作相关
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++ string类用法(转载)
首先,为了在我们的程序中使用string类型,我们必须包含头文件 。如下: #include //注意这里不是string.h string.h是C字符串头文件 1.声明一个C++字符串 声明一个字符串变量很简单: string Str; 这样我们就声明了一个字符串变量,但既然是一个类,就有构造函数和析构函数。上面的声明没有传入参数,所以就直接使用了string的默认的构造函数,原创 2014-09-25 08:45:16 · 601 阅读 · 0 评论 -
bool isBST(struct tree *root)
bool isBST(struct tree *root) { static int preV = INT_MIN; if (root == NULL) return true; if (!isBST(root->left)) return false; if (root->v > preV) preV = root-原创 2014-09-25 08:45:24 · 798 阅读 · 0 评论 -
简单的读取文件中的单词
#include #include #include using namespace std; bool judegChar(char x){ return ((x > 64 && x 96 && x } int main(){ ifstream text("C:\\text.txt"); if( text.fail() ){ cout << "Can原创 2014-09-25 08:45:20 · 961 阅读 · 0 评论 -
利用队列将一维数组变成完全二叉树
#include using namespace std; typedef struct node { int data; struct node *lchild,*rchild; } btree; btree *Q[100]; btree *CREATREE(int a[],const int n){ btree *x= new btree[n]; for (int m=0; m原创 2014-09-25 08:45:26 · 1877 阅读 · 0 评论 -
层次遍历二叉树
template <class T> void BinaryTree::easyOrder(BTNode *tr) { int front=0,rear=1; BTNode *cq[200],*p; //定义结点的指针数组cq cq[1]=tr; int NodeNum=Node(tr); while(front!=rear) {原创 2014-09-25 08:45:31 · 686 阅读 · 0 评论 -
关于函数二义性的问题
#include using namespace std; void f(int a){ cout << "f( int a)" } void f(int &a){ cout << "f( int &a)" } void main(){ const int b = 0; f(b); }原创 2014-09-25 08:45:18 · 731 阅读 · 0 评论 -
标准复数类
#include #include using namespace std; templateclass Complex{ private: T Real; T Image; public: Complex(){ Real=0; Image=0; } Complex(T a){原创 2014-09-25 08:45:22 · 706 阅读 · 0 评论 -
按层次 建立二叉树
#include "stdio.h" #include "stdlib.h" #define max 100 #define null 0 typedef struct node { char data; struct node *lchild,*rchild; } btree; btree *Q[max]; //定义队列 btree *CREATREE(){ //非递归建立二叉原创 2014-09-25 08:45:28 · 2190 阅读 · 0 评论
分享