码迷,mamicode.com
首页 >  
搜索关键字:namespace    ( 41927个结果
单词翻转(i am a student)--->>(student a am i)
问题描述: 写一个函数将i am a student  转化为  student a am i 解题思路: //i am a student --->--> student a am i #include using namespace std; /*翻转函数--->利用交换*/ void words_reverse(char str[],int left,int right) ...
分类:其他好文   时间:2015-05-01 22:37:29    阅读次数:186
POJ 3984 bfs
作了一年的ACMer竟然现在才学BFS。。。 好吧,BFS第一题 赤裸裸的裸题 1 #include 2 #include 3 #include 4 using namespace std; 5 int a[10][10]; 6 struct node 7 { 8 i...
分类:其他好文   时间:2015-05-01 22:27:06    阅读次数:183
拓扑排序模板
拓扑排序是对ADG(有向无环图进行线性排序)模板:队列实现#include#include#include#includeusing namespace std;int indegree[100];queue q;int n,m;bool map[100][100];int a[100];int t...
分类:编程语言   时间:2015-05-01 21:14:34    阅读次数:226
Linux下C/C++连接MySql
首先确保已经安装有MySql的开发包ubuntu下执行如下命令安装,其他发行版请自行查阅apt-get install libmysqlclient-dev范例代码如下:#include #include #include #include using namespace std;int main(...
分类:数据库   时间:2015-05-01 19:57:00    阅读次数:148
hdu 1754 块状链表 单点修改+单点查询
经典的线段树题目,也可以用块状链表做。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int N = 200000; 8 const int M = 800; 9 ...
分类:其他好文   时间:2015-05-01 19:55:21    阅读次数:109
贪心 Codeforces Round #301 (Div. 2) A. Combination Lock
题目传送门 1 /* 2 贪心水题:累加到目标数字的距离,两头找取最小值 3 */ 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 const int MAXN = 1e3 + 10;11...
分类:其他好文   时间:2015-05-01 19:54:03    阅读次数:127
bnuoj 27411 堆或单调队列维护区间RMQ
很显然n方的复杂度过不了。于是考虑优化最值的查询,可以考虑用堆或者单调队列来做。堆: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int INF = 99999999; 8 con...
分类:其他好文   时间:2015-05-01 18:42:10    阅读次数:134
C++得到一个数组的最大递减数组({3,9,4,5,0}得到结果是{9,4,0})
#include using namespace std; template struct Node { T data; Node *link; Node():data(T()),link(NULL){} }; template struct M_Node { Node *adj;//保存节点指针. T data; //保存当前递减数字个数. }; template class...
分类:编程语言   时间:2015-05-01 17:28:53    阅读次数:171
字符串翻转的两种方法(1:利用额外空间 2:交换)
#include using namespace std; #define STRLENTH 100 char *str_reverse1(char *str) { char temp[STRLENTH];//字符数组:存放逆序后的字符 char *p = str; //字符指针:指向最后一个非'\0'字符 int i = 0; /*找到最后一个非'\0'字符并使p指向它*/...
分类:其他好文   时间:2015-05-01 17:28:39    阅读次数:182
C++求一个字符串中的所有回文字符串并且输出结果(字符串操作)
#include #include using namespace std; bool check(char *str)//判断这是不是一个回文字符串. { int i = 0; int j = strlen(str)-1; while(i<j) { if(*(str+i)!=*(str+j)) return false; i++; j--; } return ...
分类:编程语言   时间:2015-05-01 17:26:24    阅读次数:158
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!