随笔分类 -  练习代码

摘要:class randomGenerator { private: struct val { unsigned int min; unsigned int max; val(unsigned int a, unsigned int b) : min(a), max(b) { } }; std::map 阅读全文
posted @ 2015-07-13 09:56 SandKing 阅读(12) 评论(0) 推荐(0)
摘要:参数列表 #include <stdarg.h> #include <stdio.h> #include <string.h> #include <string> using namespace std; void stat_log(const char* format, ...) { char s 阅读全文
posted @ 2015-06-30 20:03 SandKing 阅读(2) 评论(0) 推荐(0)
摘要:2.字符串压缩 通过键盘输入一串小写字母(a~z)组成的字符串。请编写一个字符串压缩程序,将字符串中连续出席的重复字母进行压缩,并输出压缩后的字符串。 压缩规则: 1. 仅压缩连续重复出现的字符。比如字符串"abcbc"由于无连续重复字符,压缩后的字符串还是"abcbc". 2. 压缩字段的格式为" 阅读全文
posted @ 2015-06-19 14:36 SandKing 阅读(12) 评论(0) 推荐(0)
摘要:大牛:http://blog.csdn.net/sjf0115/article/details/8645991 华为校招机试试题1 1.字符串过滤 通过键盘输入一串小写字母(a~z)组成的字符串。请编写一个字符串过滤程序,若字符串中出现多个相同的字符,将非首次出现的字符过滤掉。 比如字符串“abac 阅读全文
posted @ 2015-06-17 16:08 SandKing 阅读(8) 评论(0) 推荐(0)
摘要:动态映射 安全类型向下映射 #include <iostream> #include <stdlib.h> #include <time.h> #include <vector> using namespace std; class shape{ public: shape() { count++; 阅读全文
posted @ 2015-06-15 11:52 SandKing 阅读(4) 评论(0) 推荐(0)
摘要:运算符的重载 1. 友元 2. 内部 #include <iostream> using namespace std; class CTmp{ public: //friend const CTmp operator++(CTmp& tmp); //friend const CTmp operato 阅读全文
posted @ 2015-06-15 11:49 SandKing 阅读(3) 评论(0) 推荐(0)
摘要:输入输出流的现实设置 #include <iostream> #include <fstream> #include <iomanip> using namespace std; /* 使用setprecision(n)可控制输出流显示浮点数的数字个数。C++默认的流输出数值有效位是6。 如果set 阅读全文
posted @ 2015-06-15 11:47 SandKing 阅读(12) 评论(0) 推荐(0)
摘要:友元类的一种设计 #include <stdio.h> #include <string.h> #define SZ 20 struct holder{ private: int a[SZ]; public: void initialize(); struct pointer{ private: h 阅读全文
posted @ 2015-06-15 11:46 SandKing 阅读(2) 评论(0) 推荐(0)
摘要:字符串分割 字符串和值得转换 #include <iostream> #include <vector> #include <string> #include <sstream> using namespace std; template<typename T> const char* to_str 阅读全文
posted @ 2015-06-15 11:43 SandKing 阅读(3) 评论(0) 推荐(0)
摘要:格式化输入输出 #include <iostream> #include <stdarg.h> #include <string.h> #include <string> using namespace std; void print(const char* s1, ...) { va_list a 阅读全文
posted @ 2015-06-15 11:33 SandKing 阅读(8) 评论(0) 推荐(0)