摘要:#include <time.h>double start,finish;程序运行时间,在程序开始处 用start=(double) clock(); 获得开始 时间在程序结束处用finish=(double)clock(); 获得结束 时间然后 输出 时间差 毫秒 数:printf("%.4f m
阅读全文
摘要:atof(将字符串转换成浮点型数) 相关函数 atoi,atol,strtod,strtol,strtoul 表头文件 #include 定义函数 double atof(const char *nptr); 函数说明 atof()会扫描参数nptr字符串,跳过前面的空格字符,直到遇上数字或正负符号才开始做转换,而再遇到非数字或字符串结束时('\0')才结束转换,并将结果返回。参数...
阅读全文
摘要:/* FileName: foreachString.cpp Author: ACb0y Create Time: 2011年3月20日22:20:33 Last Modify Time: 2011年3月20日22:46:43 */ #include #include using namespace std; void...
阅读全文
摘要:#include // 删除长度为len的数组dat中索引为idx的元素。 void removeArr(int *dat, int *len, int idx) { (*len)--; if (idx = *len) return; for (int i = idx; i < *len; i++) dat[i] = dat[i + 1...
阅读全文
摘要:例如:你自己定义一个函数 int max(int a,int b){... } 在这里a,b就是形参,接下来你会调用max函数,如: void main() { int c,int d; ..... max(c,d); } 这里c d就是实参 所谓形参就是在函数定义体中的参数所谓实参就是在调用函数时
阅读全文
摘要:#include // 升序数组src void sort(int *src, int len) { int tem; for (int i = 0; i src[j + 1]) { tem = src[j]; src[j] = src[j + 1]; src[j + 1] = te...
阅读全文
摘要:int len = 10; int *array = (int*)malloc(sizeof(int)*len); len++; int *array_old = array; array = (int*)realloc(sizeof(int)*len); /** *如果地址改变,代表内存在另一个地方划分了一个新的内存空间, *要释放旧的内存空间 */ if(array_old != arra...
阅读全文
摘要:把“project->配置属性->c/c++->代码生成->基本运行时检查 设置为默认值,就没有这样的错误了。关于MSDN的解释是在堆栈外面读写某数据。错误是名为RTC1的编译器检测的。又看了更多的技术文章,发现这样的错误是程序员在项目到了一定大的时候,它占用的堆栈量就比较大。我也深有体会。因为自己
阅读全文
摘要:#include int main() { int a; while (scanf("%d", &a) != EOF){ printf("输出:%d\n", a); } return 0; } /* 运行结果: 54 输出:54 5156 输出:5156 21 输出:21 ^Z */
阅读全文
摘要:说明: scanf传得必须是指针,也就是地址。 比如int a;就需要&a;但是如果是数组,数组本身表示的是数组首元素的地址。也就是int a[10]里a就表示a[0]的地址;那a[3]的地址呢?可以这样,&a[3];这就是加&的数组,如果不加呢,可以这样(a+3)就可以了,a是a[0]的地址,那么
阅读全文