码迷,mamicode.com
首页 >  
搜索关键字:include    ( 84546个结果
【c语言】输入一组整数,求出最大子序列的和
// 输入一组整数,求出最大子序列的和. // 例如:序列: - 2 11 - 4 13 - 5 - 2,则最大子序列和为20。 // 序列: - 6 2 4 - 7 5 3 2 - 1 6 - 9 10 - 2,则最大子序列和为16 #include int Max_Son(int *p, int len) { int Max_Sum = 0; int i, j;...
分类:编程语言   时间:2015-07-06 23:33:37    阅读次数:360
Observer观察者模式
#include #include #include using namespace std; //观察者模式。 //定义了一对多的关系,让多个观察对象同时监听一个主题对象, //当主题对象发生变化时,多个对象作出相应的响应。 class School { public: School(char *s) {...
分类:其他好文   时间:2015-07-06 23:33:33    阅读次数:255
【c语言】第一个只出现一次的字符题目:在字符串中找出第一个只出现一次的字符
// 第一个只出现一次的字符题目:在字符串中找出第一个只出现一次的字符。 // 如输入“abaccdeff”,则输出’b’。 #include #include char find_one(char *str) { int a[256]; int len = strlen(str); int i = 0; memset(a, 0, sizeof(a)); for (i...
分类:编程语言   时间:2015-07-06 23:32:36    阅读次数:156
Memento记忆模式
//Memento记忆模式。 #include #include using namespace std; class Memento; class Originator { public: Originator(char *s = "") { _str = new char[100]; strcpy(_st...
分类:其他好文   时间:2015-07-06 23:31:54    阅读次数:260
[华为机试真题]66.单词搜索
题目代码/*--------------------------------------- * 日期:2015-07-06 * 作者:SJF0115 * 题目:WordSearch * 来源:华为机试真题 -----------------------------------------*/ #include #include #include...
分类:其他好文   时间:2015-07-06 23:30:18    阅读次数:230
STL之nth_element()(取容器中的第n大值)
nth_element()函数   头文件:#include 作用:nth_element作用为求第n大的元素,并把它放在第n位置上,下标是从0开始计数的,也就是说求第0小的元素就是最小的数。   如:a[start,end]元素区间。排序后a[n]就是数列中第n+1大的数(下标从0开始计数)。要注意的是a[start,n),     a[n,end]内的大小顺序还不一定。只能确定a[...
分类:其他好文   时间:2015-07-06 23:29:22    阅读次数:179
类的对象和类的指针
类的对象和类的指针的区别zz如下程序:#include #include using namespace std;class Student{ public: static int number; string name;public: Student() { } void set(string s...
分类:其他好文   时间:2015-07-06 23:04:59    阅读次数:93
给出4个整数,找出最大者,使用函数嵌套
#include int max_2(int a,int b) { return a>b?a:b; } int max_4(int a,int b,int c,int d) { int m; m = max_2(a,b); m = max_2(m,c); m = max_2(m,d); return m; } int main() { int a,b,c,d; printf("p...
分类:其他好文   时间:2015-07-06 21:46:40    阅读次数:99
汉诺塔-递归实现
#include void move(char x,char y) { printf("%c->%c\n",x,y); } //将n个盘子从1中借助2移动到3 void hanoi(int n,char one,char two,char three) { if(n==1) move(one,three); else { hanoi(n-1,one,two,three); mo...
分类:其他好文   时间:2015-07-06 21:46:33    阅读次数:111
insert sort 插入排序
#pragma once #include #include template void InsertSort(list& container) { std::list::iterator it_min = container.begin(); std::list::iterator it_temp...
分类:编程语言   时间:2015-07-06 21:25:12    阅读次数:168
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!