上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: #include<stdio.h>int main(){int t,n,i,j,a[111111],sum,max,start,end,l;scanf("%d",&t);for(j=1;j<=t;j++){scanf("%d",&n);sum=0;l=0;max=-1001;//题上给出了数值范围,定一个更小的确保都能进行运算;for(i=0;i<n;i++){scanf("%d",&a[i]);if(sum>=0)//已定sum=0;也就是说要从第一个数开始;(1)sum=sum 阅读全文
posted @ 2012-11-08 09:25 MFT 阅读(140) 评论(1) 推荐(0) 编辑
摘要: 动态规划解决问题的一般思路。拿到多阶段决策最优化问题后,第一步要判断这个问题是否可以用动态规划解决,如果不能就要考虑搜索或贪心了。当却定问题可以用动态规划后,就要用下面介绍的方法解决问题了:(1)模型匹配法: 最先考虑的就是这个方法了。挖掘问题的本质,如果发现问题是自己熟悉的某个基本的模型,就直接套用,但要小心其中的一些小的变动,现在考题办都是基本模型的变形套用时要小心条件,三思而后行。这些基本模型在先面的分类中将一一介绍。(2)三要素法仔细分析问题尝试着确定动态规划的三要素,不同问题的却定方向不同:先确定阶段的问题:数塔问题,和走路问题(详见解题报告)先确定状态的问题:大多数都是先确定状态的 阅读全文
posted @ 2012-11-07 23:01 MFT 阅读(466) 评论(0) 推荐(0) 编辑
摘要: //============================================================================// Name : find.cpp// Author : mtt// Version :// Copyright : Your copyright notice// Description : Hello World in C++, Ansi-style//============================================================================#include <ios 阅读全文
posted @ 2012-11-07 17:11 MFT 阅读(280) 评论(0) 推荐(0) 编辑
摘要: #include <string> size_type find_first_not_of(const string &str,size_type index =0 )const; size_type find_first_not_of(const Char* str,size_type index =0 )const; size_type find_first_not_of(const Char* str,size_type index,size_type num )const; size_type find_first_not_of(Char ch,size_type 阅读全文
posted @ 2012-11-07 16:23 MFT 阅读(237) 评论(0) 推荐(0) 编辑
摘要: / string::assign #include <iostream> #include <string> using namespace std; int main () { string str; string base="The quick brown fox jumps over a lazy dog."; // used in the same order as described above: str.assign(base); cout << str << endl; str.assign(base,10,9) 阅读全文
posted @ 2012-11-06 20:00 MFT 阅读(230) 评论(0) 推荐(0) 编辑
摘要: INT_MIN是一个已经定义的整型数据的最小值,使用这个值前应该先#include <limits.h>,这个包里当然还有其他的,类似INT_MAX,例如:#include <stdio.h>#include <limits.h>void main(){int a=INT_MIN;printf("%d",a);} 阅读全文
posted @ 2012-11-05 22:52 MFT 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 把一整数转换为字符串itoa(i,num,10); i ----需要转换成字符串的数字 num---- 转换后保存字符串的变量 10---- 转换数字的基数(即进制)。10就是说按10进制转换数字。还可以是2,8,16等等你喜欢的进制类型 返回值:指向num这个字符串的指针程序例: #include <stdlib.h> #include <stdio.h> int main(void) { int number = 12345; char string[25]; itoa(number, string, 10); printf("integer = %d.. 阅读全文
posted @ 2012-11-05 22:49 MFT 阅读(245) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>voidIntToStr(intiNum,charszNum[]){intiTmp=0;charszReverse[20]={0};intiCnt=0;while(iNum){iTmp=iNum%10;szReverse[iCnt]='0'+(iTmp-0);iNum/=10;iCnt++;}for(inti=0;iCnt;i++,iCnt--){szNum[i]=szReverse[iCnt-1];}}voidmain(){intiNum=0;charszNum[20]={0};scanf("%d",& 阅读全文
posted @ 2012-11-05 22:45 MFT 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 1.自己写一个函数(c/c++)#include<stdio.h> #include<assert.h> /*my string to integer function*/intmyfun(char*str){inti=0,n=0,flag=1;if(str[0]=='-')i=1;flag=-1;for(;str[i]!='/0';i++){assert(str[i]>='0'&&str[i]<='9');n=str[i]-'0'+n*10;}returnn*f 阅读全文
posted @ 2012-11-05 22:42 MFT 阅读(322) 评论(0) 推荐(0) 编辑
摘要: // 直接插入排序.cpp : 定义控制台应用程序的入口点。 // #include <fstream> #include <iostream> using namespace std;#include<string> #include <stdlib.h> #include <time.h> #include <stdio.h> #include <malloc.h> #define CLOCKS_PER_SEC ((clock_t)1000) int Max; //产生随机数头文件 struct su { 阅读全文
posted @ 2012-11-05 21:54 MFT 阅读(208) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 8 下一页