摘要: 开始用的是vector<sta#include<iostream>#include<cstring>#include<vector>#include<stack>using namespace std;struct card{ char ch[2];};bool is_match(card a,card b){ if(a.ch[0]==b.ch[0]||a.ch[1]==b.ch[1])return 1; return 0;}int main(){ card ca; vector<stack<card> > pile 阅读全文
posted @ 2012-05-02 22:27 open your eyes 阅读(526) 评论(0) 推荐(0) 编辑
摘要: 不知道 为什么一老是runtime error,求指点,谢谢#include<iostream>#include<vector>#include<cctype>#include<string>#include<algorithm>using namespace std;void init_vector(vector<int>v[],int sum){ for(int i=0;i<sum;i++) v[i].push_back(i);}int find_value(vector<int> v[],int v 阅读全文
posted @ 2012-05-02 20:06 open your eyes 阅读(1109) 评论(0) 推荐(0) 编辑
摘要: cin<<,cin.get,cin.getline等函数深入分析很多初学者都认为cin函数是一个很简单的函数,其实不然!cin函数有很多需要了解的知识(比如:cin的返回值是什么,cin提供了哪些成员函数且分别是什么作用,如cin.clear(),cin.ignore(),cin.fail(),cin.good()等等),如果没有很好的掌握,在使用的时候很可能会出问题却不知其原因!而且很多人也确确实实遇到过不少问题,以下是几个简单的例子:程序1:#include<iostream>usingnamespacestd;intmain(){intm,n;cin>> 阅读全文
posted @ 2012-05-02 14:15 open your eyes 阅读(438) 评论(0) 推荐(0) 编辑
摘要: C++中负责的输入/输出的系统包括了关于每一个输入/输出操作的结果的记录信息。这些当前的状态信息被包含在io_state类型的对象中。io_state是一个枚举类型(就像open_mode一样),以下便是它包含的值。goodbit 无错误 Eofbit 已到达文件尾 failbit 非致命的输入/输出错误,可挽回 badbit 致命的输入/输出错误,无法挽回 这四个标记位均为bit位,标记值为0或者1,每个标记位0表示清除,1表示设置。其中failbit,badbit,Eofbit组成了流状态。当这3个标记位都设置为0,则流状态正常,3个标记位某一个或几个设置为1时,流状态出现相应的问题。而g 阅读全文
posted @ 2012-05-02 14:11 open your eyes 阅读(776) 评论(0) 推荐(1) 编辑
摘要: 一:修改显示时使用的计数系统 控制整数以什么进制显示 1.十进制 cout<<dec 2.十六进制cout<<hex 3.八进制cout<<oct二:调整字段宽度(默认右对齐) int width():返回字段宽度的当前格式; int width(int i):将宽度设置为i个空格,并返回以前的字段宽度值注意:width()方法只影响将显示的下一个项目,然后字段宽度将恢复到默认值三:填充字段 cout.full('*'); 设置一直有效直到新的设置四:设置浮点数的显示精度 c++的默认精度为6位(末尾0不显示)方法:cout.precisio 阅读全文
posted @ 2012-05-02 13:51 open your eyes 阅读(513) 评论(0) 推荐(0) 编辑
摘要: 一:put()1.原型(适用于wchar_t)显示字符:osrteam &put (char);2:该函数返回一个指向调用对象的引用,因此可以拼接输出cout.put('i').put('t');3:自动类型转换cout.put(66);cout.put(66.3);(=cout.put(66));二:write()1:原型显示整个字符basic_ostream<charT,traits>& write(const char_type* s,streamsize n);const char * state="hello&qu 阅读全文
posted @ 2012-05-02 00:42 open your eyes 阅读(4177) 评论(0) 推荐(0) 编辑
摘要: 一:类型定义:1. const signed char *;2. const unsigned char *;3. const char *;4. void *.二: 举例char name[20]="hello world ! ";char * pn="china";cout<<"Hello!";cout<<name;cout<<pn;三:获得地址int eggs =12;char *amount = "dozen";cout<< &eggs;cout< 阅读全文
posted @ 2012-05-02 00:20 open your eyes 阅读(347) 评论(0) 推荐(0) 编辑