上一页 1 ··· 7 8 9 10 11 12 13 下一页
摘要: 1 / transform algorithm example 2 #include // std::cout 3 #include // std::transform 4 #include // std::vector 5 #include // std::plus 6 7 int op_increase (int i) { return ++i; } 8 9 int main () {10 std::vector foo;11 std::vector bar;12 13 // set some values:14 for (int... 阅读全文
posted @ 2013-08-09 21:22 OpenSoucre 阅读(374) 评论(0) 推荐(0) 编辑
摘要: insert iterators 插入型迭代器 (1)front inserters 前向插入迭代器 只适用于提供有push_front()成员函数的容器,在标准程序库中这样的容器是deque和list list coll1; deque coll2; for(int i = 1; i coll1; vector coll2; for(int i = 1; i coll1; set coll2; for(int i = 1; i <= 9 ; i ++ ){ coll1.push_back(i); } ... 阅读全文
posted @ 2013-08-09 09:38 OpenSoucre 阅读(297) 评论(0) 推荐(0) 编辑
摘要: c++使用智能指针应该保证无论在何种情况下,只要自己被摧毁,就一定连带释放其所有资源,而由于智能型指针本身就是区域变量,所以无论是正常退出,还是异常退出,只要函数退出,它就一定销毁 常数型auto_ptr减少了“不经意转移拥有权”所带来的危险,只要一个对象通过auto_ptr传递,就可以使用常数型auto_ptr来终结拥有权转移链此后拥有权将不再进行转移 阅读全文
posted @ 2013-08-08 21:38 OpenSoucre 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 注意BOOL是不能直接存放在NSMutableArray中的NSNumber* yesObj = [NSNumber numberWithBool:YES];NSMutableArray* arr = [[NSMutableArray alloc] initWithObjects: yesObj, yesObj, yesObj, yesObj, nil];NSLog(@"%d", [[arr objectAtIndex:1] boolValue]); 阅读全文
posted @ 2013-08-05 13:28 OpenSoucre 阅读(426) 评论(0) 推荐(0) 编辑
摘要: template >class MyClass{ private: T value; public: /* void assign(const MyClass& x){ value = x.value; }*/ template void assign(const MyClass& x){ value = x.value; } T getValue() const{ //表示这个函数不会修改类成员 return value; } const T setAndGet... 阅读全文
posted @ 2013-08-04 23:54 OpenSoucre 阅读(216) 评论(0) 推荐(0) 编辑
摘要: (1)并列数据之间用逗号(2)映射用冒号(3)并列数据集合用方括号(4)映射集合用大括号JSON格式例子:[ {"姓名":"python","年龄":100}, {"姓名":"c++", "年龄":200} ] 阅读全文
posted @ 2013-08-01 12:29 OpenSoucre 阅读(212) 评论(0) 推荐(0) 编辑
摘要: //下一个最大的二次幂inline int nextPowerOfTwo(int x){ x |= (x >> 1); x |= (x >> 2); x |= (x >> 4); x |= (x >> 8); x |= (x >> 16); return x + 1;}//判断是不是2的幂inline bool isPowerOfTwo(int x){ bool result = x > 0 && (x & (x - 1)) == 0; return result;} 阅读全文
posted @ 2013-07-25 11:44 OpenSoucre 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 利用模板templateinline void swap(T& a, T& b){ T tmp = a; a = b; b = tmp;}利用宏定义#define SWAP( x , y) ({__typeof__(x) temp = (x);x=y; y = temp;}) 阅读全文
posted @ 2013-07-25 11:31 OpenSoucre 阅读(300) 评论(0) 推荐(0) 编辑
摘要: fork函数在新的子进程中运行相同的程序,新的子进程是父进程的一个复制品。execve函数在当前进程的上下文中加载并运行一个新的程序。它会覆盖当前进程的地址空间,但并没有创建一个新的进程。新的程序仍然有相同的PID,并且继承了调用execve函数已打开的所有文件描述符 阅读全文
posted @ 2013-07-21 20:05 OpenSoucre 阅读(597) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 5 int main(){ 6 int r,c; 7 cin >>r>>c; 8 vector row(r,false),col(c,false); 9 char ch;10 for(int i = 0 ; i > ch;13 if(ch == 'S') row[i] = col[j] = true;14 }15 }16 int cnt = 0;17 for(int i = 0 ; i < ... 阅读全文
posted @ 2013-07-21 18:05 OpenSoucre 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 4 using namespace std; 5 6 int main(){ 7 int n,m; 8 cin >> n >> m; 9 vector flag(n+1,false);10 for(int i = 0 ; i > a>>b;13 flag[a]=flag[b]=true;14 }15 int centerPoint = 0;16 for(int i = 1 ; i <= n ; i ++ ){17 if(!flag[i]){18 ... 阅读全文
posted @ 2013-07-21 18:03 OpenSoucre 阅读(300) 评论(2) 推荐(0) 编辑
摘要: cocos2d 遍历CCAarrayCCARRAY_FOREACH(children_, node){} 阅读全文
posted @ 2013-07-19 11:37 OpenSoucre 阅读(187) 评论(0) 推荐(0) 编辑
摘要: cocos2d 中判断CGPoint是否相等 调用CGPointEqualToPoint(point1, point2)判断CGSize是否相等 调用CGSizeEqualToSize(size1,size2) 阅读全文
posted @ 2013-07-19 11:33 OpenSoucre 阅读(677) 评论(0) 推荐(0) 编辑
摘要: (1)写程序时最好在类的init函数中显示类名,表明现在在执行哪个类,样例代码 CCLOG(@"cocos2d: Using Director Type:%@", [self class]);(2)最好在类中添加一个描述该类相关信息的函数,样例代码:- (NSString*) description{ return [NSString stringWithFormat:@"", [self class], self, winSizeInPoints_.width, winSizeInPoints_.height, view_];}(3)在每个函数中添加一 阅读全文
posted @ 2013-07-17 15:11 OpenSoucre 阅读(222) 评论(0) 推荐(0) 编辑
摘要: [self class] 返回当前类名[self _cmd] 返回当前方法名self 是类的隐藏的参数,指向当前当前调用方法的类另一个隐藏参数是_cmd,代表当前类方法的selector 阅读全文
posted @ 2013-07-17 13:05 OpenSoucre 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 协议相当于接口委托相当于帮助实现其它类的功能object-c提供的协议机制,一个类可以实现多个协议,从而感觉上像多继承一样 阅读全文
posted @ 2013-07-17 12:21 OpenSoucre 阅读(300) 评论(0) 推荐(0) 编辑
摘要: (1)将*.pvr.ccz文件转换为CCSpriteBatchNode(2) 将对应的plist文件读到CCSpriteFrameCache中(3) 从CCSpriteFrameCache获取资源文件 CCSpriteBatchNode *backgoundBgNode = [CCSpriteBatchNode batchNodeWithFile:@"background.pvr.ccz"]; [self addChild:backgoundBgNode]; [[CCSpriteFrameCache sharedSpriteFrame... 阅读全文
posted @ 2013-07-16 16:03 OpenSoucre 阅读(300) 评论(0) 推荐(0) 编辑
摘要: 协议的声明/定义调用协议设置委托协议的实现 阅读全文
posted @ 2013-07-15 11:30 OpenSoucre 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 打开新立得软件管理器在右边找到有关语言的安装后,language support就会出现 阅读全文
posted @ 2013-07-14 11:21 OpenSoucre 阅读(561) 评论(0) 推荐(0) 编辑
摘要: 在新版本的cocos2d中ARCH_OPTIMAL_PARTICLE_SYSTEM已经被移除由CCParticleSystemQuad取代CCParticleSystem *test = [ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:@"test.plist"];应该改为CCParticleSystem *test=[CCParticleSystemQuad particleWithFile:@"test.plist"]; 阅读全文
posted @ 2013-07-12 12:07 OpenSoucre 阅读(344) 评论(0) 推荐(0) 编辑
摘要: 当将大量精灵加载到CCLayer时,如果直接利用[self addChild:sprite]去加载,每加载一个精灵,都必须open,draw,close,而利用CCSpriteBatchNode去加载时只有一次open,draw,close,减少了精灵open,close的时间,但CCSpriteBatchNode有缺点精灵都存放在集合中,那么这个集合CCSpriteBatchNode中的节点(精灵)都将在同一个z轴上,同一深度上 阅读全文
posted @ 2013-07-12 11:42 OpenSoucre 阅读(189) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;int main(){ int n,m; cin >> n >> m; cout<<n+m-1<<endl; for(int i = 1; i <= m ; i ++) cout<<1<<" "<<i<<endl; for(int i = 2; i <= n; i ++ ) cout<<i<<" "<<m<< 阅读全文
posted @ 2013-07-04 14:18 OpenSoucre 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 当一个scene中同时有UITapGestureRecognizer和CCMenu,点击时不会响应CCMenu,此时必须对UITapGestureRecognizer进行设置 UITapGestureRecognizer *tapGestureRecognizer =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTapGestureRecognizer:)]; tapGestureRecognizer.cancelsTouchesInView = NO; [s... 阅读全文
posted @ 2013-07-02 16:00 OpenSoucre 阅读(222) 评论(0) 推荐(0) 编辑
摘要: [button setEnable:NO];[button setAlpha:0.4]; 阅读全文
posted @ 2013-07-01 11:07 OpenSoucre 阅读(1606) 评论(0) 推荐(0) 编辑
摘要: fork一个进程后,复制出来的task_struct结构与系统的堆栈空间是父进程独立的,但其他资源却是与父进程共享的,比如文件指针,socket描述符等不同的进程使用不同的地址空间,子进程被创建后,父进程的全局变量,静态变量复制到子进程的地址空间中,这些变量将相互独立 1 #include 2 #include 3 #include 4 #include 5 6 int count = 1; 7 8 int main(){ 9 if(fork() == 0){10 count--;11 printf("child fork:counter =... 阅读全文
posted @ 2013-06-30 17:38 OpenSoucre 阅读(3133) 评论(0) 推荐(0) 编辑
摘要: 1、同步请求可以从因特网请求数据,一旦发送同步请求,程序将停止用户交互,直至服务器返回数据完成,才可以进行下一步操作,2、异步请求不会阻塞主线程,而会建立一个新的线程来操作,用户发出异步请求后,依然可以对UI进行操作,程序可以继续运行参考文档:http://www.dreamingwish.com/dream-category/api-in-chinese/asihttprequest-doc官方文档:http://allseeing-i.com/ASIHTTPRequest/Setup-instructions 阅读全文
posted @ 2013-06-27 11:15 OpenSoucre 阅读(325) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std;int main(){ long long n; cin >>n; while(n){ if(n%10 == 1) n/=10; else if(n%100 == 14 ) n/=100; else if(n%1000 == 144) n/=1000; else { cout<<"NO"<<endl;return 0;} } cout<<"YES"<<endl; return 0;} 阅读全文
posted @ 2013-06-24 00:01 OpenSoucre 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 题目题意是交换一次,使数字最小,且数字前面不能有前导0 string minNumber(string num) { string res = num; for(int i = 0 ; i < num.size(); i ++ ){ for(int j = i + 1; j < num.size(); j ++ ){ if(i == 0 && num[j] == '0') continue; else{ sw... 阅读全文
posted @ 2013-06-19 09:05 OpenSoucre 阅读(334) 评论(0) 推荐(0) 编辑
摘要: 无论是谁,如果他没有在编程上下功夫,没有花费大量的时间,那么他不会成为编程高手。这就意味着,当别人都已入睡或者在Happy时,而你需要日以继夜的工作,为你的职业生涯努力奋斗。 阅读全文
posted @ 2013-06-16 18:12 OpenSoucre 阅读(151) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#define LL long longusing namespace std;int main(){ LL n,k; cin >> n >>k; LL split = n%2 ? n/2+1 : n/2; if( k <= split ) cout<<-1+2*k<<endl; else cout<<2*(k-split)<<endl; return 0;} 阅读全文
posted @ 2013-06-15 11:29 OpenSoucre 阅读(192) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;int main(){ string text; cin >> text; vector<int> heavyPos,metalPos; size_t pos = 0; while((pos = text.find("heavy",pos)) != string::npos) heavyPos.push_back(pos 阅读全文
posted @ 2013-06-15 11:28 OpenSoucre 阅读(189) 评论(0) 推荐(0) 编辑
摘要: ios app 25个 改善程序性能技巧http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks 阅读全文
posted @ 2013-06-13 18:57 OpenSoucre 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 1. Create a NSOperationQueue to handle background downloading.NSOperationQueue *operationQueue = [[NSOperationQueue alloc]init];2. Now create an NSInvocationOperation for each image that you want to download and add it to operationQueue.int noOfImages = 500;for(int i = 0; i noOfImages; i++){NSInvoc. 阅读全文
posted @ 2013-06-13 18:51 OpenSoucre 阅读(817) 评论(0) 推荐(0) 编辑
摘要: 1.在执行$ git remote addorigin git@github.com:defnngj/hello-world.git错误提示:fatal: remote origin already exists.解决办法:$ git remote rm origin然后在执行:$ git remote add origin git@github.com:xxxx/hello-world.git 就不会报错误了2. 在执行$ git push origin master错误提示:error:failed to push som refs to.......解决办法:$ git pull ori 阅读全文
posted @ 2013-06-12 23:01 OpenSoucre 阅读(193) 评论(0) 推荐(0) 编辑
摘要: c#提供了一个关键字sealed来防止发生继承,如果我们将类标记为sealed,编译器将不会允许我们从这个类型派生c#结构总是隐式密封的,因此我们不可以从结构继承结构,从类继承结构或从结构继承类,结构只能用于建模独立的用户定义的数据类型。如果希望使用is-a关系,必须使用类。 阅读全文
posted @ 2013-06-09 09:28 OpenSoucre 阅读(129) 评论(0) 推荐(0) 编辑
摘要: + (UIImage *)addTwoImageToOne:(UIImage *)oneImg twoImage:(UIImage *)twoImg topleft:(CGPoint)tlPos{ UIGraphicsBeginImageContext(oneImg.size); [oneImg drawInRect:CGRectMake(0, 0, oneImg.size.width, oneImg.size.height)]; [twoImg drawInRect:CGRectMake(tlPos.x, tlPos.y, twoIm... 阅读全文
posted @ 2013-06-06 11:33 OpenSoucre 阅读(360) 评论(0) 推荐(0) 编辑
摘要: NSLog打印日志我们需要开关,在release时需要关掉所有日志(否则当然很浪费内存),当然我们也可以使用宏定义来实现。但是还是有些麻烦!CCLog里面封装了NSLog,使用起来就方便多了了,因为它只在debug时候调用,在release时不调用 阅读全文
posted @ 2013-06-04 11:58 OpenSoucre 阅读(248) 评论(0) 推荐(0) 编辑
摘要: (1)引入命名空间,在引入命名空间的当前代码页写程序代码时,可以免除长长的命名空间。 (2)在程序代码过中,使用using,可以在using结束时,回收所有using段内的内存。 try { using (StreamReader sr = new StreamReader("TestFile.txt")) { string line; while ((line = sr.ReadLine()) != null) { Co... 阅读全文
posted @ 2013-05-27 11:43 OpenSoucre 阅读(330) 评论(0) 推荐(0) 编辑
摘要: t=[-1:2/(2^12):1];x=63*sawtooth(pi*(t+0.5),0.5)+64;plot(t,x) 阅读全文
posted @ 2013-05-26 13:45 OpenSoucre 阅读(2545) 评论(0) 推荐(0) 编辑
摘要: 在cocos2d中起点坐标(x=0, y=0)位于左下角,这意味着屏幕位于X轴从屏幕最左边开始,由左向右渐增Y轴坐标从屏幕最下方开始,由下向上渐增[sprite setAnchorPoint:ccp(0.5,0.5)]锚点:中心 默认[sprite setAnchorPoint:ccp(0,0)]锚点:左下角[sprite setAnchorPoint:ccp(0,1)]锚点:左上角[sprite setAnchorPoint:ccp(1,0)]锚点:右下角[sprite setAnchorPoint:ccp(1,1)]锚点:右上角setPosition为外层锚点与本层锚点的距离参考博客:ht 阅读全文
posted @ 2013-05-24 11:38 OpenSoucre 阅读(1165) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 下一页