05 2012 档案
摘要:1.dynamic_cast2.const_cast3.static_cast4.reinterpret_cast
阅读全文
摘要:#include<iostream>#include<string>using namespace std;int flag=1;typedef struct node{ int W1,D1,Wr,Dr; struct node *left,*right;}bitnode,*bitree;void createtree(bitree *T){ bitnode bit; cin>>bit.W1>>bit.D1>>bit.Wr>>bit.Dr; *T=new node; (*T)->D1=bit.D1; (*T)->
阅读全文
摘要:#include<iostream>#include<string>#include<cctype>#include<map>#include<cstring>#include<iterator>using namespace std;int main(){ string sa; while(getline(cin,sa)) { cout<<"Expression: "<<sa<<endl; int k,i,j,flag=0,sum=0; string temp=&q
阅读全文
摘要:#include<iostream>#include<cstdlib>#include<string>#include<malloc.h>#include<map>using namespace std;map<int,int>ma;int flagg=0;typedef struct node{ int data; struct node*left; struct node* right; int flag;}bitnode,*bitree;void createbittree(bitree *T,int flag3){
阅读全文
摘要:#include<iostream>#include<malloc.h>#include<cstdio>using namespace std;const int maxn=10000+10;int minn,ans=0;typedef struct node{ int data; struct node *left,*right;}bitnode,*bitree;void createtree(bitree *T,int *in,int *post,int len){ int k; int *temp; if(len<=0) { *T=NUL...
阅读全文
摘要:#include <iostream>using namespace std;int a[100000];int nLeaves;typedef struct treeNode{ int data; treeNode*left,*right; treeNode():data(),left(NULL),right(NULL){} treeNode(int x):data(x),left(NULL),right(NULL){}}treeNode;inline bool isnum(char ch){ return ((ch>='0' && ch&l
阅读全文
摘要:还记得vector怎么使用吗?valarray类似vector,也是一个模板类,其主要被用来对一系列元素进行高速的数字计算,其与vector的主要区别在于以下两点 1、valarray定义了一组在两个相同长度和相同类型的valarray类对象之间的数字计算,例如xarr = cos(yarr) + sin(zarr); 2、通过重载operater[],可以返回valarray的相关信息(valarray其中某个元素的引用、特定下标的值或者其某个子集)。如果想对两个vector进行一些运算,如第一个vector的对象元素加上第二个vector的对应元素,还得写个for循环,或调用相应的库函数.
阅读全文
摘要:#include<iostream>#include<cstring>using namespace std;int main(){ int sum; cin>>sum; while(sum--) { int n,p; cin>>n; cin.ignore(); cin>>p; cin.ignore(); int i,j,a[3660]; memset(a,0,sizeof(a)); int temp,lose=0; for(i=0;i<p;i+...
阅读全文
摘要:#include<iostream>#include<queue>#include<cstring>#include<string>using namespace std;const int maxn=1000+10;int main(){ int n,sum=1; while(cin>>n) { if(n==0)break; int i,j; int map[maxn*maxn]; int visit[maxn]; memset(visit,-1,sizeof(visit)); memse...
阅读全文
摘要:string插入一个字符s.insert((string::size_type)0,1,'a');先由stack的后缀表达式得到原表达式的树,再由queue得到后缀表达式#include<iostream>#include<stack>#include<queue>#include<cctype>#include <algorithm> #include<string>#include<cstring>using namespace std;struct node{ char ch; int l
阅读全文
摘要:#include<iostream>#include<stack>#include<cctype>#include<map>#include<string>using namespace std;struct matrix{ int x,y;};int main(){ int n; cin>>n; char ch; int i,x,y; matrix ma; map<int,matrix> m; for(i=0;i<n;i++) { cin>>ch; cin.ignore(); cin>
阅读全文
摘要:#include<iostream>#include<string>#include<stack>using namespace std;int main(){ int n; cin>>n; cin.ignore(); while(n--) { string temp; getline(cin,temp); if(temp=="") { cout<<"Yes"<<endl; } else { stack<char> s; ...
阅读全文
摘要:乌龟王国的乌龟总是一只一只叠在一起。唯一改变乌龟位置的方法为:一只乌龟爬出他原来的位置,然后往上爬到最上方。给你一堆乌龟原来排列的顺序,以 及我们想要的乌龟的排列顺序,你的任务是按照先后次序列出出哪只乌龟需往上爬,使得可以产生所要的乌龟排列顺序,且爬的动作要发生最少。Input输入的第一列有一个整数,代表以下有多少组测试资料。每组测试资料的第一列有1个整数 n (n<=200),代表乌龟的数目。接下来的 n 列每列有一只乌龟的名字(乌龟名字均为唯一,且仅包含字符、空白、句点,长度不会超过80个字符),代表原来乌龟排列的顺序(由上到下)。再接下来的 n 列每列也有一只乌龟的名字,代表我们想
阅读全文
摘要:#include<iostream>#include<cstdio>#include<malloc.h>#include<cstdlib>using namespace std;typedef struct cicle{ int data; struct cicle *next; struct cicle *prior;}list;list *createcyclelist(int n){ list *head=NULL; list *s,*q; s=(list*)malloc(sizeof(list)); head=s; q=s; h...
阅读全文
摘要:开始用的是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
阅读全文
摘要:不知道 为什么一老是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
阅读全文
摘要: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>>
阅读全文
摘要:C++中负责的输入/输出的系统包括了关于每一个输入/输出操作的结果的记录信息。这些当前的状态信息被包含在io_state类型的对象中。io_state是一个枚举类型(就像open_mode一样),以下便是它包含的值。goodbit 无错误 Eofbit 已到达文件尾 failbit 非致命的输入/输出错误,可挽回 badbit 致命的输入/输出错误,无法挽回 这四个标记位均为bit位,标记值为0或者1,每个标记位0表示清除,1表示设置。其中failbit,badbit,Eofbit组成了流状态。当这3个标记位都设置为0,则流状态正常,3个标记位某一个或几个设置为1时,流状态出现相应的问题。而g
阅读全文
摘要:一:修改显示时使用的计数系统 控制整数以什么进制显示 1.十进制 cout<<dec 2.十六进制cout<<hex 3.八进制cout<<oct二:调整字段宽度(默认右对齐) int width():返回字段宽度的当前格式; int width(int i):将宽度设置为i个空格,并返回以前的字段宽度值注意:width()方法只影响将显示的下一个项目,然后字段宽度将恢复到默认值三:填充字段 cout.full('*'); 设置一直有效直到新的设置四:设置浮点数的显示精度 c++的默认精度为6位(末尾0不显示)方法:cout.precisio
阅读全文
摘要:一: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
阅读全文
摘要:一:类型定义: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<
阅读全文

浙公网安备 33010602011771号