上一页 1 ··· 116 117 118 119 120 121 122 123 124 ··· 300 下一页
2013年9月9日

c coding style之学习篇

摘要: 1. 使用do-while结构去避免潜在的内存泄漏问题。do { p1 = malloc(10); if (null == p1) { break; } p2 = malloc(20); if (null == p2) { break; } return ok; }while(0);de_init(); return fail;2. 使用指针时必须先检查指针的有效性,这样做的一大好处是可以防止误用null pointer而引起系统crash。if (p1 != null) { do_something(); } else { printf("\nnull pointer... 阅读全文
posted @ 2013-09-09 20:28 you Richer 阅读(160) 评论(0) 推荐(0)

COCOS2D中对精灵的操作、对图片的各种操作

摘要: 内容简要:1、初始化 2、创建无图的精灵 3、设置精灵贴图大小 4、添加入层中5、对精灵进行缩放 6、对精灵宽或高进行缩放 7、旋转精灵8、设置精灵透明度 9、精灵的镜像反转 10、设置精灵的颜色11、得到图的宽高 12、按照像素设定图片大小 13、在原有的基础上加xy的坐标14、设置图片锚点 15、从新排列z轴顺序 16、更换精灵贴图17、设置可视区域 18、贴图无锯齿//初始化 CCSprite* sprite =[CCSprite spriteWithFile:@"Icon.png"];//创建无图的精灵CCSprite*sprite2 =[CCSprite node 阅读全文
posted @ 2013-09-09 20:26 you Richer 阅读(159) 评论(0) 推荐(0)

hdu 1060 Leftmost Digit

摘要: 思路:sm=n^n,两边分别对10取对数得 log10(m)=n*log10(n),得m=10^(n*log10(n)),由于10的任何整数次幂首位一定为1,所以m的首位只和n*log10(n)的小数部分有关; #include #include int main() { int T; double ans1; __int64 ans2,ans,n; scanf("%d",&T); while(T--) { scanf("%I64d",&n); ans1=n*log10(double(n)); ans2=__int64(ans1); an 阅读全文
posted @ 2013-09-09 20:23 you Richer 阅读(151) 评论(0) 推荐(0)

hdu 4284 Travel(floyd + TSP)

摘要: 虽然题中有n#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define FF(i, a, b) for(int i=a; i=b; i--)#define REP(i, n) for(int i=0; i w) g[u][v] = g[v][u] = w; } FF(k, 1, n+1) FF(i, 1, n+1) FF(j, 1, n+1) g[i][j] = min(g[i][j], ... 阅读全文
posted @ 2013-09-09 20:22 you Richer 阅读(227) 评论(0) 推荐(0)

利用Android手机里的摄像头进行拍照

摘要: ------- 源自梦想、永远是你IT事业的好友、只是勇敢地说出我学到! ---------- 1.在API Guides中找到Camera,里面讲解了如何使用系统自带的摄像头进行工作,之后我会试着翻译这部分的内容。2.找到Camera类:有android.hardware.Camera和android.graphics.Camera两个类,我们这里使用android.hardware.Camera。使用Camera类来拍照的步骤如下(API 原文):Obtain an instance of Camera fromopen(int).Get existing (default) setti. 阅读全文
posted @ 2013-09-09 20:19 you Richer 阅读(551) 评论(0) 推荐(0)

Cocos2d-x 创建(create)动画对象CCAnimation报错分析

摘要: 本人在使用精灵表单创建动画的过程中突然遇到了一些个问题,下面进行一下分析总结。 根据在Cocos2d-iphone中的经验,我写出了如下的代码:CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("my.plist"); CCSpriteBatchNode *batchNode = CCSpriteBatchNode::create("my.png"); this->addChild(batchNode); CCArray *frameArray = CC 阅读全文
posted @ 2013-09-09 20:17 you Richer 阅读(399) 评论(0) 推荐(0)

JavaScript初学者应知的24条最佳实践(译)

摘要: 原文:24 JavaScript Best Practices for Beginners译者:youngsterxyf(注:阅读原文的时候没有注意发布日期,觉得不错就翻译了,翻译到JSON.parse那一节觉得有点不对路才发现是2009年发布的文章,不过还是不错的啦。另外,文章虽说24条最佳实践,其实只有23条,不知道原作者怎么漏了一条。)1.优先使用===,而不是==JavaScript使用两种相等性操作符:===|!==和==|!=。通常认为做比较的最佳实践是使用前一组操作符。“若两个操作数的类型和值相同,那么===比较的结果为真,!==比较的结果为假。” — JavaScript语言精 阅读全文
posted @ 2013-09-09 20:14 you Richer 阅读(222) 评论(0) 推荐(0)

C++自删除

摘要: #pragma onceclass AutoRelease{public: AutoRelease(void){ m_count = 0; } virtual ~AutoRelease(void){} AutoRelease* GetPointClone() { ++m_count; return this; } void Release() { m_count = m_count - 1; if( m_count #include "AutoRelease.h"using namespace std;class A:public AutoRelease{};void ma 阅读全文
posted @ 2013-09-09 20:12 you Richer 阅读(454) 评论(0) 推荐(0)

hdu 4715

摘要: #include #include int prime[1100000],p[1000000],ans; void pri() { int i,j,k; memset(prime,-1,sizeof(prime)); prime[0]=prime[1]=0; for(i=2;i=x&&prime[p[i]-x]==-1) break; if(i==ans) printf("FAIL\n"); else printf("%d %d\n",p[i],p[i]-x); } return 0; } 阅读全文
posted @ 2013-09-09 20:10 you Richer 阅读(133) 评论(0) 推荐(0)

URAL 1056(树形DP)

摘要: 1056. Computer Net Time limit: 2.0 second Memory limit: 64 MB Background Computer net is created by consecutive computer plug-up to one that has already been connected to the net. Each new computer gets an ordinal number, but the protocol contains the number of its parent computer in the net.... 阅读全文
posted @ 2013-09-09 20:08 you Richer 阅读(163) 评论(0) 推荐(0)
上一页 1 ··· 116 117 118 119 120 121 122 123 124 ··· 300 下一页