
自我学习
thz1598746
生就像一杯茶,不能苦一辈子,总要苦一阵子。
展开
-
操作系统学习之路一
通过《深入理解操作系统》一书,我现在学习到第三章,对于第二章中的我学到了移码,以及数在机器中的表示方式,对于计算的溢出的判断等等有了进一步的了解,,,,,,,,,,好了,明天再详细的写,,今天到此原创 2012-11-22 23:20:01 · 194 阅读 · 0 评论 -
字符串相似度
#include #include #include using namespace std;//算法int ldistance(const string source,const string target){ //step 1 int n=source.length(); int m=target.length();原创 2012-09-14 16:01:19 · 140 阅读 · 0 评论 -
先写入文件在读入屏幕
#include #include using namespace std;int main(){ fstream in_out; in_out.open("a.txt",ios::in|ios::out|ios::trunc); in_out.write("hello",5); in_out.seekg(0,ios::beg原创 2012-09-14 16:00:49 · 428 阅读 · 0 评论 -
迷宫求解
#include #include #include #include #include #include using namespace std;struct PathUnit{ int x; int y; int direct;};class MyMaze{ vector >vecMaze;原创 2012-09-14 16:00:15 · 198 阅读 · 0 评论 -
关联迭代器
关联容器两个基本的关联容器map和set如果希望有效的存储不同值的集合,那么使用set容器比较合适,而map容器则更适用于需要存储(乃至修改)每个键所关联的值的情况。在做某种文本处理时,可使用set保存要忽略的单词,而字典则是map的一种很好的应用:单词本身是键,而他的解释说明是值set和map类型的对象所包含的元素都具有不同的键,不允许为同一个键添加第二个元素。如果一个键必须原创 2012-09-13 10:32:27 · 165 阅读 · 0 评论 -
图的邻接表存储以及深度和广度遍历
#include #include using namespace std;struct ArcNode{ int adjvec;//邻接点域 ArcNode *next;};struct VertextNode//定义顶点表节点{ int vertex; int visited; ArcNode *fi原创 2012-09-07 21:07:34 · 267 阅读 · 0 评论 -
N皇后
# include int main(){ int a[10], n, i = 1, b; a[1] = 1; scanf("%d", &n); while(1) { b = 1; for(int j = i - 1; j >= 1; j--) {原创 2012-09-08 21:38:38 · 709 阅读 · 0 评论 -
集合划分
#include using namespace std;int f(int n,int m)//对n个数划分为m个{ if(m==1||n==m) return 1; else return f(n-1,m-1)+f(n-1,m)*m;//第m个为单独元素和地m个为非独立元素}int main()原创 2012-09-08 16:26:19 · 170 阅读 · 0 评论 -
对数字进行排序并删除其中相等的
#include #include #include #include using namespace std;int main(){ istream_iterator cin_it(cin), end_of_stream; vector v(cin_it,end_of_stream); ostream_iterator o(c原创 2012-08-16 23:08:28 · 307 阅读 · 0 评论 -
简单实现了数学运算的先后问题
#include #include #include #include using namespace std;int precede(const char a){ switch(a) { case'+': case'-': return 0; case'*': case'原创 2012-09-05 23:54:44 · 195 阅读 · 0 评论 -
字符串流
#include #include using namespace std;int main(){ int n; float f; string s; string st = "1 .3 666"; istringstream t(st); stringstream t1; t>>n; t>>f原创 2012-09-14 16:01:38 · 170 阅读 · 0 评论 -
将文本输入到文件
#include #include using namespace std;struct S{ char name[20]; int grade;};int main(){ ofstream out; out.open("a.txt"); S s1 = {"田宏增",90}; S s2 =原创 2012-09-14 16:01:59 · 128 阅读 · 0 评论 -
绪论
数据数据是信息的载体,在计算机科学中是指所有能输入到计算机并能被计算机程序识别和处理的符号集合。数据元素数据元素也称为节点,是表示数据的基本单位,在计算机程序中通常作为一个整体进行考虑和处理数据项数据项是构成数据元素的不可分割的最小单位。数据对象数据对象是具有相同性质的数据元素的集合,是数据的子集数据结构数据结构是指相互之间存在一原创 2012-09-14 16:02:23 · 255 阅读 · 0 评论 -
两个数字第一个不相等的元素
#include #include using namespace std;int main(){ int a1[]={1,2,3,4,5,6}; int a2[]={1,2,3,2,3,3}; pairb = mismatch(a1,a1+6,a2); cout return 0;}原创 2012-09-14 16:06:26 · 131 阅读 · 0 评论 -
最长公共字串
#include #include #include using namespace std;int main(){ string a; string b; cin >> a; cin >> b; int n1, n2; n1 = a.length(); n2 = b.length();原创 2012-09-14 16:05:51 · 149 阅读 · 0 评论 -
get系列
#include using namespace std;int main(){ char *a = new char; cin.getline(a,10);//读取一行,提取界定符 cout cin.get(a,10);//读取一行,不提取界定符,,,cin.ignore(),,,清除缓冲区 cout原创 2012-09-14 16:05:15 · 167 阅读 · 0 评论 -
处理流错误
#includeusing namespace std;int main(){ int a; cout cin>>a; cout if(cin.good()) { cout } if(cin.fail()) { cout }原创 2012-09-14 16:04:52 · 232 阅读 · 0 评论 -
将文本按行显示
#include #include using namespace std;int main(){ cout char s[100]; ifstream in("a.txt"); if(!in) return 0; while(in.getline(s,100)) { cout原创 2012-09-14 16:04:30 · 676 阅读 · 0 评论 -
单词统计
#include #include #include #include #include #include using namespace std;class CWord{ string word;public: CWord(string word) { this->word = word;原创 2012-09-14 16:04:08 · 227 阅读 · 0 评论 -
重载运算符一
重载操作符是具有特殊名称的函数:保留字operator后接需定义的操作符号。像任意其他函数一样,重载操作符具有返回类型和形参表,如下语句:Sales_item operator+(const Sales_item&,const Sales_item&);声明了加号操作符,可用于将两个Sales_item对象相加并获得一个Sales_item对象的副本。不能重载的操作符::原创 2012-09-14 16:03:38 · 267 阅读 · 0 评论 -
find查询函数
#include #include #include using namespace std;bool tian(int n){ return n>5;}int main(){ vector a; vector v; for(int i = 0; i { a.push_back(i原创 2012-09-14 16:03:10 · 159 阅读 · 0 评论 -
计数
#include #include #include using namespace std;bool tian(int i){ return i }int main(){ vector a(10,5); for(int i = 0; i { a.push_back(i); } cout原创 2012-09-14 16:02:49 · 123 阅读 · 0 评论 -
模板的简单使用
#include using namespace std;template int tian(T t1, T t2){ if(t1>t2) return 1; if(t1 return -1; return 0;}int main(){ cout cou原创 2012-09-03 23:06:45 · 131 阅读 · 0 评论 -
面向对象编程一
面向对象编程的关键思想是多态性。之所以称通过继承而相关联的类型为多态性,是因为在许多情况下可以互换地使用派生类型或基类型的许多形态动态绑定动态绑定我们能够编写程序使用集成层次中任意类型的对象,无须关系对象的具体类型。使用这些类的程序无须区分函数是在基类还是在派生类中定义的基类通常应将派生类需要重定义的任意函数定义为虚函数。有时作为基类的类具有的一些成员,它希原创 2012-09-03 22:58:25 · 135 阅读 · 0 评论 -
输入流的简单使用
#include#include#include#includeusing namespace std;int main(){ vector v; istream_iterator tian(cin); istream_iterator hong;// vectorv(tian,hong); while(tian!=原创 2012-08-16 23:05:58 · 140 阅读 · 0 评论 -
输出流的简单使用
#include#include#include#includeusing namespace std;int main(){ ostream_iterator out_iter(cout,"\n"); istream_iterator in_iter(cin), eof; while(in_iter!=eof) *(原创 2012-08-16 23:09:12 · 127 阅读 · 0 评论 -
迭代器算法1
查找两个迭代器标记范围内的一个值,使用find函数所在头文件是algorithm类似的,由于指针的行为与作用在内置数组上的迭代器一样,因此也可以使用find来搜索数组int a[6] = {1,2,2,2,3,4};int *result = find(ia,ia+6,1);泛型算法本身从不执行容器操作,只是单独依赖迭代器和迭代器操作实现。算法基于迭代器及其操作实现,而并非基于容器原创 2012-08-15 23:28:22 · 159 阅读 · 0 评论 -
输入输出流
C++ 通过以下几个类支持文件的输入和输出ofstream写操作的文件类由ostream引申而来ifstream读操作的文件类由istream引申而来fstream可同时读写操作的文件类由iostream引申而来ifstream in("tian.txt");//打开一个文件ifstream in;in.open("tian.txt",mode);ist原创 2012-08-15 23:16:34 · 161 阅读 · 0 评论 -
输入流错误eof faile bad
#include #include #include #include const int sz = 100;using namespace std;int main(){ int m; while(cin>>m,!cin.eof()) { if(cin.bad()) throw runt原创 2012-08-15 23:19:44 · 222 阅读 · 0 评论 -
main函数两个参数的作用
int main(int argc, char **argv)int main(int argc, char*argv[])这两个参数的作用:argc是指命令行输入参数的个数(以空白符分隔)argv存储了所有的命令行参数,加入你的程序是hello.exe,如果在命令行运行该程序,其运行命令为 hello.exe shiqi yu那么argc的值是3argv[0]是“hell原创 2012-08-15 23:18:32 · 154 阅读 · 0 评论 -
简单的读取和写入文件
#include #include #include const int sz = 100;using namespace std;int main(){ char buf[sz]; ifstream in("tian.txt"); assert(in); ofstream out("hong.txt");原创 2012-08-15 23:15:37 · 143 阅读 · 0 评论 -
输入流状态条件访问
rdstate成员函数返回一个iostate类型的值,该值对应于流当前的整个状态条件istream::iostate old_state = cin.rdstate();cin.clear();process_input();//use cincin.clear(old_state);原创 2012-08-15 23:27:34 · 364 阅读 · 0 评论 -
读取一行单词分开输出
#include #include #include using namespace std;void t(ifstream &in, string &s){ in.close(); in.clear(); in.open(s.c_str()); char buf[100]; while(in.getline(b原创 2012-08-15 23:17:54 · 150 阅读 · 0 评论 -
迭代器算法2
插入迭代器:这类容器可与容器绑定在一起实现在容器中插入元素的功能iostream迭代器:这类容器可与输入或输出流绑定在一起,用于迭代器遍历。反向迭代器:这类迭代器实现向后遍历,而不是向前遍历。所有容器类型都定义了自己的reverse_iterator类型。有rbegin和rend成员函数返回back_iterator,创建使用push_back实现插入的迭代器。fron原创 2012-08-16 23:06:32 · 344 阅读 · 0 评论 -
iterator的简单使用
#include #include #include #include #include using namespace std;int main(){ vector v; listl; for(int i = 0; i { v.push_back(i); } for(int原创 2012-08-16 23:07:07 · 127 阅读 · 0 评论 -
排除重复单词2
#include #include #include #include #include #include using namespace std;int main(){ listword; string next_word; while(cin>>next_word) { word.push原创 2012-08-16 23:07:50 · 166 阅读 · 0 评论 -
有重复数字的排列
#include using namespace std;int a[4] = {0,0,1,1};void tian(int m, int n){ if(m == n) { for(int i = 0; i { cout } cout return; } else{ for(int i = m; i {原创 2012-09-04 20:54:01 · 185 阅读 · 0 评论 -
整数划分
#include using namespace std;int x[10]={100};void f(int a,int b){ if(0==a) { for(int i = 0; i { cout } cout return; } for(int i = a; i > 0; i--) { if((b-1>=0) &原创 2012-09-04 19:51:21 · 114 阅读 · 0 评论 -
赫夫曼编码
#include #include using namespace std;struct tree{ int weight;//权值 int rchild;//右孩子 int lchild;//左孩子 int parent;//父亲};void g(vector &t){ int size = t.s原创 2012-08-21 01:32:34 · 246 阅读 · 0 评论 -
重载运算符(一)
重载操作符是具有特殊名称的函数:保留字operator后接需定义的操作符号。像任意其他函数一样,重载操作符具有返回类型和形参表,如下语句:Sales_item operator+(const Sales_item&,const Sales_item&);声明了加号操作符,可用于将两个Sales_item对象相加并获得一个Sales_item对象的副本。不能重载的操作符::原创 2012-08-29 22:58:30 · 150 阅读 · 0 评论