码迷,mamicode.com
首页 >  
搜索关键字:namespace    ( 41927个结果
分治法解决最大子数组问题
利用分治法解决最大子数组问题(对给定的数组得到该数组中具有最大和的子数组)/* * 对于给定的整数数组A,求出数组中具有最大和的子数组,最大和以及左右下标 * 思路:采用分治的方法,将数组分为两部分,则有最大和的子数组共有三种情况 * 在数组左边,在数组右边,跨越数组中点 */#include using namespace std;//存放左右边界值以及sum值的结构...
分类:编程语言   时间:2015-04-16 09:08:35    阅读次数:153
UVA 146 ID Codes
求用这些字母的下一个排列是什么。直接使用C++ STL库里面的next_permutation#include#include#includeusing namespace std;int main(){ char s[1000]; while (~scanf("%s", s)) ...
分类:其他好文   时间:2015-04-16 07:58:45    阅读次数:184
codeforces #535 div 2
暂时做了4题,先放一下有时间做最后一题(当然如果我真的能做出的话。。。)A题:英文单词别拼错就没什么问题吧#include #include using namespace std;char str[10][10] = {"" , "" , "twenty" , "thirty" , "forty"...
分类:其他好文   时间:2015-04-16 06:42:09    阅读次数:162
归并排序---数组
/*merge sort*/#include using namespace std;const int max_num = 1000000000;void mergeData(int *s, int p, int q, int r){ int n1 = q - p + 1; int n...
分类:编程语言   时间:2015-04-16 01:27:56    阅读次数:212
小心指针被delete两次
有时候使用到传值调用(对象实体做参数),遇到这种情况,可要小心了!特别是当你所传值的对象生命周期较长,而非临时对象(生命周期段)的时候。来看看下面的情况: #include using namespace std; class Text { private: char * str; ...
分类:其他好文   时间:2015-04-16 01:11:28    阅读次数:284
题目:返回一个一维循环数组中最大子数组的和
#include #include #define N 10using namespace std;int maxxunhuan(int array[N] , int n){ int i,j = 0,m,c = 0; int sum = array[0],b = 0,max = 0; f...
分类:编程语言   时间:2015-04-16 01:09:14    阅读次数:176
崩溃!!!大家帮我看看问题出在哪???链表的倒序
今天在做PAT题时,有一道是这样的基本方法,就是用链表做,和用数组做呗,习惯性的先用数组做了,结果出了问题 1 #include 2 #include 3 using namespace std; 4 5 int main() 6 { 7 int count, renum; 8 ...
分类:其他好文   时间:2015-04-16 01:08:17    阅读次数:143
环数组求最大子数组的和
在结对开发的过程中,每个人分担不同的任务,由于我们在学习阶段,所以我自己也编写了一段小程序,但是总是缺少一个限制条件,让这段代码停下来,下面这段代码是我的同伴编写的,我只是做了一个测试。#includeusing namespace std;void main(){ int length; ...
分类:编程语言   时间:2015-04-16 01:07:27    阅读次数:137
函数递归——赶羊
namespace 赶羊递归 { class Program { public int jisuan(int day) //创建一个函数,输入day计算出羊的总数 { int sum=0; if(day==7) { sum = 2; return sum; //一定要加return截止 } su.....
分类:其他好文   时间:2015-04-16 01:04:05    阅读次数:352
找到一段话中第二个关键字的位置
namespace 找到一段话中第二个关键字的位置{ class Program { static void Main(string[] args) { //找第二个a string s = "cabcaceadf"; int n = s.IndexOf("a"); //找到第一个a的索引n str...
分类:其他好文   时间:2015-04-16 01:03:09    阅读次数:127
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!