码迷,mamicode.com
首页 >  
搜索关键字:assert    ( 2161个结果
C语言中的assert
assert宏的原型定义在中,其作用是如果它的条件返回错误,则终止程序执行。 库函数: assert.h 原型定义: void assert( int expression ); assert的作用是现计算表达式 expression ,如果其值为假(即为0),那么它先向stderr打印一条出错信息,然后通过调用 abort 来终止程序运行。 例程: #include #in...
分类:编程语言   时间:2016-05-12 15:46:49    阅读次数:171
小代码 寻找K个最大的数
/***************************** 复杂度: ***************************/ #include<iostream> #include<assert.h> #include<vector> #include<stdlib.h> #include<time.h> usingnamespacestd; #defineN1000 #defineK100 voidAdjustDown(int*a..
分类:其他好文   时间:2016-05-10 23:54:53    阅读次数:391
小代码 反转单链表和 反转前K个节点的单链表
/******************** WZASUST2016代码与反思 ********************/ #include<iostream> #include<assert.h> #include<vector>//容器--类模板 #include<stdlib.h>//利用随机值 #include<time.h> usingnamespacestd; #defineN1000 #defineK1..
分类:其他好文   时间:2016-05-10 23:46:05    阅读次数:292
堆的实现
堆结构的二叉树存储是最大堆:每个父节点的都大于孩子节点。最小堆:每个父节点的都小于孩子节点。孩子节点下面,我们以小堆为例,实现堆的建立:代码如下:#pragmaonce #include<iostream> #include<vector> #include<assert.h> usingnamespacestd; templa..
分类:其他好文   时间:2016-05-10 18:52:21    阅读次数:165
打印1到最大的n位数。
输入数字n,按顺序打印出从1最大的n位十进制数。(1)直接通过n定位到最大的数大一的数,然后打印出来。缺陷:有可能数值超出计算机存储数据基本类型的范围,所以就得采用第二种方法。1#include<stdio.h> 2#include<assert.h> 3#include<math.h> 4voidMAX_NUM..
分类:其他好文   时间:2016-05-09 14:28:51    阅读次数:235
斐波那契数列的第n项。
第一种:递归函数1#include<stdio.h> 2#include<stdlib.h> 3#include<assert.h> 4 5intFabonacci(intn) 6{ 7if(n<=1&&n>=0) 8{ 9returnn; 10} 11returnFabonacci(n-1)+Fabonacci(n-2); 12} 13intmain() 14{ 15intn; 16printf("pleaseinputthev..
分类:其他好文   时间:2016-05-09 07:19:58    阅读次数:271
小代码 二分查找之部分有序
#include<iostream> usingnamespacestd; intfindx(int*xx,intx,intn) { //assert(xx); intl=0;intr=n;intmid=r/2; if(xx[l]==x)returnl; if(xx[mid]==x)returnmid; if(xx[r]==x)returnr; if(xx[l]<xx[mid])r=mid; elsel=mid; if(xx[l]<x&&x<xx[r]); e..
分类:其他好文   时间:2016-05-08 20:05:34    阅读次数:255
SoftwareTest- Junit, hamcrest and eclemma.
a) 关于Junit hamcrest 1,从网站上下载junit的新版本,这里下载的是junit4.12 2,在myeclipse中新建一个java项目,并build path,即添加到类路径中 3,新建一个类Triangel,其功能主要实现判断三角形的类型 4, 创建Test类,用到Assert ...
分类:其他好文   时间:2016-05-08 18:18:06    阅读次数:194
strchr 、 strrchr 、strrstr的实现
#include<stdio.h> #include<stdlib.h> #include<assert.h> char*my_strchr(constchar*dst,charc) { assert(dst); constchar*pdst=dst; while(*pdst) { if(*pdst==c) return(char*)pdst; else pdst++; } returnNULL; } intmain() { charc=0..
分类:其他好文   时间:2016-05-07 16:48:31    阅读次数:147
Unity 模仿官方例子 点击时添加爆炸力
这里需要有一些爆炸的粒子特效,如果大家没有的话,我会打包在项目中,这是我在网上下载的一些特效,里面有很多特效,我就只用了其中一个来做测试。 爆炸特效的路径在:Assert–>JMO Assert–>WarFX–>Explosions首先创建好一个3D项目,做出如下类似的场景。 注意:需要给立方体添加Rigidbody(刚体)组件,不然没有效果。给摄像机添加一个Boom脚本,编辑如下:using...
分类:编程语言   时间:2016-05-07 06:53:23    阅读次数:432
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!