上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页
摘要: Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What constitutes a word?A sequence of non-space characters constitutes a word.Could the input string contain leading o 阅读全文
posted @ 2014-03-24 14:15 OpenSoucre 阅读(154) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文
posted @ 2014-03-24 00:37 OpenSoucre 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 对于static 的全局变量,其对链接器不可以见,也就是说,这个变量只能在当前文件中使用。 阅读全文
posted @ 2014-03-18 10:50 OpenSoucre 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 让对角线的元素为k就行#include using namespace std;int main() { int n,k; cin >> n >> k; for(int i = 0 ; i < n; ++ i){ for(int j = 0 ; j < n ; ++ j){ if(j != 0) cout<<" "; if( i == j) cout<<k; else cout<<0; } cout<<endl; } return 0;} 阅读全文
posted @ 2014-03-15 19:35 OpenSoucre 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 解题思路:如果序列a是单调递增的,则序列为1,2,..... 2n,则将给出的式子化简得Σ(a2i - a2i-1) = n如果序列a是单调递减的,则序列为2n,.........2, 1,则将给出的式子化简得为0故本题的解决方法是前面2k个序列即a1,a2......a2k是单调递增的,后面的序列是单调递减的#include using namespace std;int main(){ int n , k; cin >> n >> k; bool flag = false; for(int i = 1; i 2*k; --i){ if(!flag) ... 阅读全文
posted @ 2014-03-15 19:15 OpenSoucre 阅读(187) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;int main(){ int n,m; cin >> n >> m; int a[50][50]; bool flag = false; for(int i = 0 ; i > a[i][j]; } } for(int j = 0; j < m; ++ j){ if(a[0][j] || a[n-1][j]){ flag = true; break; } } for(int i... 阅读全文
posted @ 2014-03-15 18:38 OpenSoucre 阅读(203) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;int main(){ int n,k,l,r,s_n,s_k; cin >> n >> k >> l >> r >> s_n >> s_k; int s_n_k = s_n-s_k; int average_k = s_k/k,left_k = s_k%k; vector a(n,0); for(int i = 0 ; i < k ; ++ i ){ a[i] = average_k; if(i < left_k) 阅读全文
posted @ 2014-03-15 16:22 OpenSoucre 阅读(168) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;int main(){ int n, m , k; cin >> n >> m >> k; int first_type = 0, second_type = 0; for(int i = 0 ; i > a; (a == 1) ? first_type++ : second_type ++ ; } int wash_number = 0; if(first_type - m >= 0 ){ wash_number = first_type - m; ... 阅读全文
posted @ 2014-03-15 15:48 OpenSoucre 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 一般方法:#include #include #include using namespace std;//形如abaint oneCenter(string const& str, int index){ int len = 1 , i = 1; while((index-i)>=0 && (index+i)= 0 && (index+1+i > str; cout<<"Max longest string lenght is " <<solve(str) <<endl;} 阅读全文
posted @ 2014-03-13 23:10 OpenSoucre 阅读(189) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;int main(){ int n; cin >> n; string str; cin >> str; long long cnt = 0, x = 1; for(int i = 0 ; i < n ; ++ i){ if(str[i] == 'B') cnt+=(x << i); } cout<<cnt<<endl;}Codeforces Round #233 (Div. 2) 阅读全文
posted @ 2014-03-13 21:12 OpenSoucre 阅读(157) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;int main(){ int n,p,k; cin >> n >> p >> k; bool hasLeft = true, hasRight = true; int first = p-k,last = p + k; if( p - k = n) last = n,hasRight = false; if(hasLeft) cout>"<<endl;} 阅读全文
posted @ 2014-03-13 20:53 OpenSoucre 阅读(144) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;int main(){ int n,m; cin >> n >> m; if(n > (m + 1) || m > (n + 1)*2 ) cout= m) { for(int i = 0; i =m){ for(int i = 0; i< m - n; ++ i) cout<<"110"; for(int i =m-n; i < n; ++ i ) cout<< "10"; }else{ for(int i 阅读全文
posted @ 2014-03-13 19:56 OpenSoucre 阅读(152) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;int main(){ int x,k; cin >> x >> k; vector num(x+1, false); num[x] = true; for(int i = 0 ; i > index; if( index == 1){ cin >> num1 >> num2; num[num1]=num[num2] = true; }else{ cin >> num1; ... 阅读全文
posted @ 2014-03-12 23:47 OpenSoucre 阅读(212) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;int main(){ int n,x; cin >> n >> x; int sum = 0; for(int i = 0 ; i > number; sum +=number; } if(sum < 0) sum = -sum; cout<<(sum%x ? sum/x+1 : sum/x) <<endl;} 阅读全文
posted @ 2014-03-12 22:36 OpenSoucre 阅读(207) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std;typedef pair Point;int n,m;void clockwise_rotate(Point &cell, int x){ for(int i = 0; i > n >> m >> x >> y >> z >> p; x %=4; y %=2; z %= 4; int tmp_n = n,tmp_m = m; for(int i = 0 ; i > cellX >> cellY 阅读全文
posted @ 2014-03-09 22:08 OpenSoucre 阅读(210) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;const int num = 6;const int item[] = {1,2,3,4,6,12};int main(){ int t; cin >> t; for(int i = 0 ; i > character; vector result; for(int j = 0 ; j = a) break; } if(col < b) result.push_back(a); } ... 阅读全文
posted @ 2014-03-08 21:08 OpenSoucre 阅读(273) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include using namespace std;int main(){ int n,m; cin >> n >> m; set distance; bool flag = true; for(int i = 0 ; i > rectangle; int dwarf_pos = rectangle.find('G'); int candy_pos = rectangle.find('S'); int dist = candy_pos - d... 阅读全文
posted @ 2014-03-08 21:06 OpenSoucre 阅读(319) 评论(0) 推荐(0) 编辑
摘要: 参考http://www.toolsandapplications.com/guided-access-how-to-disable-the-home-button-on-ipad/ 阅读全文
posted @ 2014-02-20 11:32 OpenSoucre 阅读(498) 评论(0) 推荐(0) 编辑
摘要: 根据http://www.merowing.info/2012/04/drawing-smooth-lines-with-cocos2d-ios-inspired-by-paper/用cocos2d画线时出现闪烁问题原有的画线部分放在CCLayer的draw函数里面-(void)draw{ [renderTexture begin]; 画线部分 [renderTexture end];}由于draw每帧时都执行,故draw频繁调用,出现闪烁,解决方法是利用update,[self schedule:@selector(update:) interval:1.0/60];-(v... 阅读全文
posted @ 2014-02-12 15:24 OpenSoucre 阅读(339) 评论(0) 推荐(0) 编辑
摘要: [xxx timeIntervalSinceNow]出现EXC_BAD_ACCESS错误的主要原因是之前的[NSDate date]返回一个autoreleased的NSdata,其被释放掉解决方法第一种方法是将该文件变成ARC的,让系统自动管理内存第二种方法是增加引用计数,让其不被释放,[[NSDate date]retain] 但最后要记得手动释放 阅读全文
posted @ 2014-02-11 21:35 OpenSoucre 阅读(474) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std;int main(){ int n; cin >> n; vector board(n); int cnt = 0; for(int i = 0 ; i > board[i]; } for(int i = 1 ; i < n-1; i ++ ){ for(int j = 1 ; j < n-1; j ++ ){ if(board[i][j] == '#' && board[i-1][j] == '#' &a 阅读全文
posted @ 2014-02-10 00:01 OpenSoucre 阅读(158) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std;int main(){ int n; cin >> n; vector x(n,0); for(int i = 0 ; i > x[i]; } bool flag = true; while(flag){ flag = false; sort(x.begin(),x.end()); for(int i = n - 1; i >=1; i -- ){ if(x[i]-x[i-... 阅读全文
posted @ 2014-02-09 23:31 OpenSoucre 阅读(146) 评论(0) 推荐(0) 编辑
摘要: printf("%p",a);取变量的地址 阅读全文
posted @ 2014-01-20 15:56 OpenSoucre 阅读(282) 评论(0) 推荐(0) 编辑
摘要: (1)出现"std::__1::basic_ostream >::flush()"之类的错误Undefined symbols for architecture i386: "std::__1::basic_ostream >::flush()", referenced from: cv::gpu::error(char const*, char const*, int, char const*) in opencv2(gpumat.o) "std::__1::basic_ostream >::sentry::sentry(s 阅读全文
posted @ 2013-12-31 16:15 OpenSoucre 阅读(1031) 评论(0) 推荐(0) 编辑
摘要: 解决方法是添加libxml2.dylib然后在Build Settings 中的Header Search Paths 添加:${SDK_DIR}/usr/include/libxml2 阅读全文
posted @ 2013-12-27 11:12 OpenSoucre 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 第一种解决方法是去github上下载最新的CCBReader第二种解决方法是把other替换成self.inner建议用新版本的 阅读全文
posted @ 2013-12-17 11:47 OpenSoucre 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 首先导入libxml2.dylib,具体怎么导入跟导入frameworks一样然后在Build Setting中的Header Search Paths to: 添加${SDK_DIR}/usr/include/libxml2 阅读全文
posted @ 2013-12-17 11:39 OpenSoucre 阅读(467) 评论(0) 推荐(0) 编辑
摘要: 今天在利用AFNetworking做网络请求时总是能看到添加的CCSprite精灵总是延迟一会才显示,google了半天没有找到答案,考虑到CCSprite要被渲染才能显示,于是直接在场景中的CCLayer的draw函数上添加了一个断点,查看什么时候CCLayer才被渲染,发现每次执行下面语句时CCLayer的draw函数就不会执行,倒是CCSprite不能渲染,故执行下面函数时阻塞了draw函数的执行NSTime *_time;//开始轮询-(void)startUpdateQuery{ _timer = [NSTimer scheduledTimerWithTimeInterval:... 阅读全文
posted @ 2013-12-11 15:09 OpenSoucre 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 当向下面使用时会出现错误#import "AFNetworking.h"#import "AFURLSessionManager.h"AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];主要原因是NSURLSession模块仅支持ios7,打开AFURLSessionManager.h会看到一个宏#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && 阅读全文
posted @ 2013-12-09 12:05 OpenSoucre 阅读(2037) 评论(0) 推荐(0) 编辑
摘要: NSString *myClassName = @"MainScene";Class myClass = NSSClassFromString(myClassName); 阅读全文
posted @ 2013-12-06 16:30 OpenSoucre 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法添加一行manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];即可整个代码为: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerial 阅读全文
posted @ 2013-12-05 16:33 OpenSoucre 阅读(12280) 评论(0) 推荐(1) 编辑
摘要: 1、运算符优先级很容易引起问题,如a = 4成员选择(指针)对象指针->成员名--2-负号运算符-表达式右到左单目运算符~按位取反运算符~表达式++自增运算符++变量名/变量名++--自减运算符--变量名/变量名--*取值运算符*指针变量&取地址运算符&变量名!逻辑非运算符!表达式(类型)强制类型转换(数据类型)表达式--sizeof长度运算符sizeof(表达式)--3/除表达式/表达式左到右双目运算符*乘表达式*表达式%余数(取模)整型表达式%整型表达式4+加表达式+表达式左到右双目运算符-减表达式-表达式5>右移变量>>表达式6>大于表达式& 阅读全文
posted @ 2013-11-30 00:06 OpenSoucre 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 当将AFNetworking添加到工程后编译时出现Undefined symbols for architecture i386: "_SecCertificateCopyData", referenced from: _AFCertificateTrustChainForServerTrust in AFSecurityPolicy.o "_SecCertificateCreateWithData", referenced from: _AFPublicKeyForCertificate in AFSecurityPolicy.o "_Sec 阅读全文
posted @ 2013-11-29 14:31 OpenSoucre 阅读(996) 评论(0) 推荐(0) 编辑
摘要: 1、web页面要尽可能简单,让用户不用思考就能知道页面的功能,如果要进行一些崭新的、开拓性的或者非常复杂的页面设计时,此时要利用页面元素的外观、精心选择的名称、页面布局以及少量仔细斟酌过的文字,使页面看起来有一种解释或者识别的功能。2、在设计网页时,必须考虑到用户使用网页的三个事实:用户不是逐字的阅读,而只是扫描一下页面用户不是做最佳的选择,找到一个满意的就可以用户不是追根究底页面的运作原理,只是找个能勉强应付的3、设计web页面时,要使用户尽可能的看到并理解你的网站在每个页面上要建立清楚的层次,使页面在瞬间明白易懂,越重要的部分越突出,逻辑上相关的部分视觉上也要相关,逻辑上包含的部分视觉上要 阅读全文
posted @ 2013-11-28 23:32 OpenSoucre 阅读(411) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std;int main(){ string s ; cin >>s; int m; cin >>m; vector l(m),r(m); for(int i = 0 ; i > l[i]>>r[i]; int n = s.length(); vector x(n+1,0),y(n+1,0),z(n+1,0); for(int i = 0; i num(3,0); num[0] = x[r[i]]-x[l[i]-1... 阅读全文
posted @ 2013-11-28 22:47 OpenSoucre 阅读(283) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std;int main(){ int n,m; cin >> n >>m; vector a(n),l(m); for(int i = 0 ; i >a[i]; for(int i = 0 ; i >l[i]; set diff; vector res(n,0); for(int i = n-1;i >=0; -- i){ diff.insert(a[i]); res[i] = diff.size(); } ... 阅读全文
posted @ 2013-11-28 22:46 OpenSoucre 阅读(235) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;int main(){ int n,d; cin >> n >>d; vectora(n); for(int i = 0; i >a[i]; int m; cin >> m; sort(a.begin(),a.end()); int sum = 0; if(m <=n){ for(int i = 0 ; i < m; ++ i) sum+=a[i]; } else{ for(int i ... 阅读全文
posted @ 2013-11-28 22:45 OpenSoucre 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 1、资源竞争:当每个线程都去访问同一段内存时,会导致所谓i资源竞争问题,这时候可以通过“@synchronized block”将实例变量包围起来,创建一个互斥锁, 这样你就可以确保在互斥锁中的代码一次只能被一个线程访问:@synchronized(self){ a.object = value; }2、原子性:将一个property声明为atomic时,通常会把它包裹在一个@synchronized块中,确保是线程安全的@property (atomic, retain) NSString *myString;- (NSString *)myString { @sync... 阅读全文
posted @ 2013-11-28 14:10 OpenSoucre 阅读(253) 评论(0) 推荐(0) 编辑
摘要: NSNotificationCenter主要用于广播消息到多个监听着,其传统用法 1 - (void)viewDidLoad 2 { 3 [super viewDidLoad]; 4 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someMethod:) name:kMyNotificationIdentifier object:nil]; 5 } 6 7 - (void)dealloc 8 { 9 [[NSNotificationCenter defaultCent... 阅读全文
posted @ 2013-11-28 12:11 OpenSoucre 阅读(185) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;int main(){ int n,k,cnt = 0; cin >> n >>k; for( int i = 0 ; i goodNum(k+1,0); cin >> a; while(a){ if(a%10= k +1) cnt++; } cout<<cnt<<endl; return 0;} 阅读全文
posted @ 2013-11-24 21:31 OpenSoucre 阅读(178) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页