AgPro

导航

2010年6月11日 #

STL的vector、map、pair举例

摘要: #include #include #include #include using namespace std; int main() { vector the_vector; vector::iterator the_iterator; for( int i=0; i gMap; string strTemp = "help"; map::iterator it = gMa... 阅读全文

posted @ 2010-06-11 17:01 AgPro 阅读(2033) 评论(0) 推荐(0) 编辑

Predefined preprocessor variables

摘要: Predefined preprocessor variables Syntax: The following variables can vary by compiler, but generally work:The __LINE__ and __FILE__ variables represent the current line and current file being proces... 阅读全文

posted @ 2010-06-11 16:54 AgPro 阅读(198) 评论(0) 推荐(0) 编辑

C/C++ Reference

摘要: C/C++ Reference General C/C++ Pre-processor commands Operator Precedence Escape Sequences ASCII Chart Data Types Keywords Standard C Library Standard C I/O Standard C String & Character Standard... 阅读全文

posted @ 2010-06-11 15:45 AgPro 阅读(255) 评论(0) 推荐(0) 编辑

#include <cstdlib>的所有函数

摘要: cppreference.com > Other Standard C Functions Other Standard C Functions Display all entries for Other Standard C Functions on one page, or view entries individually: abort stops the program asser... 阅读全文

posted @ 2010-06-11 15:33 AgPro 阅读(4071) 评论(0) 推荐(0) 编辑

#pragma的作用

摘要: #pragma The #pragma command gives the programmer the ability to tell the compiler to do certain things. Since the #pragma command is implementation specific, uses vary from compiler to compiler. One ... 阅读全文

posted @ 2010-06-11 15:26 AgPro 阅读(1908) 评论(0) 推荐(0) 编辑

#error的作用

摘要: #error Syntax: The #error command simply causes the compiler to stop when it is encountered. When an #error is encountered, the compiler spits out the line number and whatever message is. This comman... 阅读全文

posted @ 2010-06-11 15:14 AgPro 阅读(1162) 评论(0) 推荐(0) 编辑

explicit

摘要: explicit When a constructor is specified as explicit, no automatic conversion will be used with that constructor -- but parameters passed to the constructor may still be converted. For example: 阅读全文

posted @ 2010-06-11 15:07 AgPro 阅读(227) 评论(0) 推荐(0) 编辑

#line的作用

摘要: #line Syntax: The #line command is simply used to change the value of the __LINE__ and __FILE__ variables. The filename is optional. The __LINE__ and __FILE__ variables represent the current file and... 阅读全文

posted @ 2010-06-11 15:03 AgPro 阅读(518) 评论(0) 推荐(0) 编辑

qsort-库函数

摘要: #include #include using namespace std; int compare_ints( const void* a, const void* b ) { int* arg1 = (int*) a; int* arg2 = (int*) b; if( *arg1 < *arg2 ) return -1; else if( *ar... 阅读全文

posted @ 2010-06-11 14:14 AgPro 阅读(172) 评论(0) 推荐(0) 编辑

归并排序--递归

摘要: #include #include using namespace std; const int MAX_SIZE = 100; int b[MAX_SIZE];// Type *b = new Type[right-left+1]; template void Merge(Type c[], Type d[], int left, int mid, int right) {//c[] l... 阅读全文

posted @ 2010-06-11 14:00 AgPro 阅读(185) 评论(0) 推荐(0) 编辑

排列和组合--递归

摘要: #include #include using namespace std; int N,M; //Pemute-------------------- void Perm( int x[], int n, int k ) { int i; if ( k == n-1 ) { for ( i=0; i=m; k-- ) { x[m] = k+1; if(m==0) ... 阅读全文

posted @ 2010-06-11 11:30 AgPro 阅读(176) 评论(0) 推荐(0) 编辑

排列--perm_next法

摘要: #include #include using namespace std; void initial(int *x,int n)//排列组合数组元素的初始化(无重复的情况) { for( int i=1;i=p[i])&&(i>=1);i--); if(i==1) return 0; for(j=n;(p[i-1]>=p[j])&&(j>=0);j--); ... 阅读全文

posted @ 2010-06-11 11:29 AgPro 阅读(198) 评论(0) 推荐(0) 编辑

生成质数数组

摘要: #include using namespace std; const int MAXP = 200; bool pm[MAXP+1]; void primes() { memset(pm,1,MAXP); int i,j; for ( i=2; i<=MAXP; i++ ) { if ( pm[i] ) { j = 2*i; while ( j<=MAXP )... 阅读全文

posted @ 2010-06-11 10:13 AgPro 阅读(271) 评论(0) 推荐(0) 编辑

最大间隙问题--线性时间实现

摘要: #include using namespace std; const int MAX_SIZE = 100; double x[MAX_SIZE]; int n; int mini() { int k=1; double temp = x[k]; for ( int i=2; itemp ) { temp = x[i]; k = i; } } return ... 阅读全文

posted @ 2010-06-11 09:41 AgPro 阅读(636) 评论(0) 推荐(0) 编辑