上一页 1 2 3 4 5 6 ··· 9 下一页
摘要: #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... 阅读全文
posted @ 2012-05-05 23:08 open your eyes 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2012-05-05 17:50 open your eyes 阅读(246) 评论(0) 推荐(0) 编辑
摘要: #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> 阅读全文
posted @ 2012-05-05 07:59 open your eyes 阅读(314) 评论(0) 推荐(0) 编辑
摘要: #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; ... 阅读全文
posted @ 2012-05-03 23:14 open your eyes 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 乌龟王国的乌龟总是一只一只叠在一起。唯一改变乌龟位置的方法为:一只乌龟爬出他原来的位置,然后往上爬到最上方。给你一堆乌龟原来排列的顺序,以 及我们想要的乌龟的排列顺序,你的任务是按照先后次序列出出哪只乌龟需往上爬,使得可以产生所要的乌龟排列顺序,且爬的动作要发生最少。Input输入的第一列有一个整数,代表以下有多少组测试资料。每组测试资料的第一列有1个整数 n (n<=200),代表乌龟的数目。接下来的 n 列每列有一只乌龟的名字(乌龟名字均为唯一,且仅包含字符、空白、句点,长度不会超过80个字符),代表原来乌龟排列的顺序(由上到下)。再接下来的 n 列每列也有一只乌龟的名字,代表我们想 阅读全文
posted @ 2012-05-03 21:22 open your eyes 阅读(220) 评论(0) 推荐(0) 编辑
摘要: #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... 阅读全文
posted @ 2012-05-03 01:17 open your eyes 阅读(358) 评论(0) 推荐(0) 编辑
摘要: 开始用的是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 2 3 4 5 6 ··· 9 下一页