C/C++杂记
文章平均质量分 52
laomahao
这个作者很懒,什么都没留下…
展开
-
String类中构造函数、拷贝构造函数、赋值函数的实现
class String { public: String(const char *str = NULL); String(const String &rhs); String &operator=(const String &rhs); ~String(); private: char *m_str; } String::String(const char *str) { if(原创 2012-03-26 16:01:15 · 2820 阅读 · 0 评论 -
写一个寻找数组中第二大的数的程序
#include using namespace std; const int MAX_INT = 200000000; int find_sec_num(int *num, int count); int main(void) { int num[] = {1,2,3,4,5,6,7,8,9}; //要查找的数组 int count = sizeof(num)/sizeof(i原创 2012-04-10 22:25:12 · 2118 阅读 · 0 评论 -
实现atoi函数
int a_to_i(const char *str) { int cur; //当前字符 int total;//当前整型数据 int sign; //数据符号 //去点前面的空白符 while(isspace((int)(unsigned char)*str)) { str++; } //如果*str最高位是1,那么直接将其付给int型时会变成负数,所以必须先转成un原创 2012-05-02 15:28:26 · 489 阅读 · 0 评论 -
hdoj 1280 前m大的数
给定一个包含N(N #include using namespace std; int main(void) { int N, M; while(cin >> N >> M) { int *temp = new int[N]; for(int i=0; i<N; ++i) { cin >> temp[i]; } int data[10005]; f原创 2012-05-11 20:04:10 · 588 阅读 · 0 评论 -
hdoj 3791 二叉搜索树
#include using namespace std; struct BiTreeNode//结点结构体 { char ch; BiTreeNode *left; BiTreeNode *right; BiTreeNode(char x, BiTreeNode *l = NULL, BiTreeNode *r = NULL) :ch(x), left(l), right(r)原创 2012-05-11 19:36:02 · 485 阅读 · 0 评论