C++ 学习
文章平均质量分 57
a15743239832
这个作者很懒,什么都没留下…
展开
-
C++ string类简单实现
#include#includeusing namespace std;class MyString{ friend ostream &operator<<( ostream &, const MyString & ); public: MyString(const char *s); MyString( ); MyString(const MyString &); ~原创 2013-05-09 23:00:14 · 730 阅读 · 2 评论 -
C++ 读取文件并统计字符数、行数和单词数
#include#include#includeusing namespace std;bool isnum_str(char str) //判断是否是字符或数字{ if((str >= 'A' && str = '0' && str <= '9') ) return true; else return false;}void count(fstream原创 2013-05-28 20:35:40 · 13752 阅读 · 2 评论 -
C++ primer ----------- 流状态的查询和控制
#include#includeusing namespace std;int main(){ int val; while(cin >> val, !cin.eof()) { if(cin.bad()) throw runtime_error("IO stream corrupted."); if(cin.fail()) {原创 2013-06-03 21:13:49 · 541 阅读 · 0 评论 -
C++ I/O操作——简单文件加密
#include#include#include/* 实现对输入文件进行简单加密和解密,然后输出到输出文件。 解密时密码需要和加密时密码一致。 */using namespace std;int main(){ string str; char buffer[256]; int psw; int a; cout <<"e原创 2013-06-05 00:42:10 · 1667 阅读 · 0 评论 -
C++ primer ————————————“单词转换" map 对象
#include#include#include#include#include#include/*单词转换:给出一个string 对象 转换成另一个string对象 :输入是两个文件 第一个 含有若干单词对 做词典功能: 第二个文件 提供了需要转换的文件。 */using namespace std;typedef pair str_s原创 2013-06-05 23:55:59 · 970 阅读 · 0 评论 -
C++ primer 统计单词个数
#include#include#include#include#include#include#includeusing namespace std;int main(){ map word_count; ifstream infile; string filename; char line[256]; cout << "In原创 2013-06-06 19:20:38 · 1681 阅读 · 0 评论 -
C++ primer 文本查询程序
#include#include#include#include#include#include#includeusing namespace std;/* 读取用户指定的任意文本文件,然后允许用户从该文本中查找单词。 查询的结果是该单词出现的次数,并列出每次出现所在的行。如果一个单词在一行 中多次出现,程序只将该行显示一次。行号按升序显示。原创 2013-06-07 19:34:54 · 1094 阅读 · 1 评论 -
static 数据成员和函数成员
#include#includeusing namespace std;class base{private: int a,b; string name;public: base(string name = " "):a(10),b(10){} // 静态成员变量不能在初始化列表中初始化 static int c; //声明静态数据成员 /原创 2013-06-24 18:28:59 · 754 阅读 · 0 评论