06 2015 档案

(六十八)使用XMPPFramework登录
摘要:按照XMPPFramework的官方样例,应该把登录代码放置在AppDelegate中,并且让注销成为私有方法。 XMPPFramework进行登录的步骤如下: ①连接主机,并且发送JID ②如果连接成功,则发送密码进行授权 ③授权成功后,发送上线消息 ④如果要注销,发送下线消息,并且断开连接。... 阅读全文

posted @ 2015-06-23 21:28 张大大123 阅读(181) 评论(0) 推荐(0)

(六十七)Xcode导入XMPPFramework框架
摘要:首先下载XMPPFramework框架,将Vendor内容导入到工程中,其中KissXML需要额外的框架,需要通过Xcode设置。 选择工程选项中TARGETS的General标签,最下侧有Linked Frameworks and Libraries,导入libxml2.dylib: 接着选... 阅读全文

posted @ 2015-06-23 21:12 张大大123 阅读(138) 评论(0) 推荐(0)

(六十六)TableView内容超过一屏时滚动到屏幕底部的方法
摘要:假设数据放置在self.chatMessage数组内,只需要让tableView滚动到最后一条数据底部即可,调用scrollToRowAtIndexPath方法: [_tableView reloadData];// 实现数据超过一屏时滚动到底部。NSIndexPath *lastPath = ... 阅读全文

posted @ 2015-06-22 19:46 张大大123 阅读(189) 评论(0) 推荐(0)

(六十五)iOS的socket实现(GCDAsyncSocket)
摘要:本文介绍使用GCDAsyncSocket来实现iOS端的socket,有关简易服务端的代码已经在上一篇文章中提到,这里不再赘述,将直接介绍如何实现客户端。 首先下载CocoaAsyncSocket框架,如果下载过iOS的XMPP框架,在Vendor中有这个框架,将框架导入工程,并包含其头文件GC... 阅读全文

posted @ 2015-06-22 19:27 张大大123 阅读(592) 评论(0) 推荐(0)

(六十四)iOS的socket实现(C+OC混合实现)
摘要:对于微博、微信朋友圈之类的网络通信,使用JSON完全可以满足需求,但是如果要制作网络游戏,就需要建立一个持久连接,这时候就要考虑使用socket。 在iOS上实现socket大体有两种方法,一是借助自带的输入输出流和C语言socket相结合,二是利用第三方类库CocoaAsyncSocket,本... 阅读全文

posted @ 2015-06-22 19:00 张大大123 阅读(252) 评论(0) 推荐(0)

1035. Password (20)
摘要:题目如下: To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing ... 阅读全文

posted @ 2015-06-12 16:58 张大大123 阅读(186) 评论(0) 推荐(0)

1036. Boys vs Girls (25)
摘要:题目如下: This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female stu... 阅读全文

posted @ 2015-06-12 16:54 张大大123 阅读(149) 评论(0) 推荐(0)

1037. Magic Coupon (25)
摘要:题目如下: The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon wit... 阅读全文

posted @ 2015-06-12 16:49 张大大123 阅读(137) 评论(0) 推荐(0)

1038. Recover the Smallest Number (30) - 字符串排序
摘要:题目如下: Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 8... 阅读全文

posted @ 2015-06-12 16:37 张大大123 阅读(415) 评论(1) 推荐(0)

1034. Head of a Gang (30) -string离散化 -map应用 -并查集
摘要:题目如下: One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A a... 阅读全文

posted @ 2015-06-10 14:23 张大大123 阅读(171) 评论(0) 推荐(0)

1031. Hello World for U (20)
摘要:题目如下: Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed a... 阅读全文

posted @ 2015-06-09 13:12 张大大123 阅读(137) 评论(0) 推荐(0)

1032. Sharing (25) -set运用
摘要:题目如下: To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share th... 阅读全文

posted @ 2015-06-09 13:03 张大大123 阅读(269) 评论(0) 推荐(0)

1033. To Fill or Not to Fill (25) -贪心算法
摘要:题目如下: With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to ... 阅读全文

posted @ 2015-06-09 12:42 张大大123 阅读(196) 评论(0) 推荐(0)

1029. Median (25)
摘要:题目如下: Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14... 阅读全文

posted @ 2015-06-05 16:00 张大大123 阅读(115) 评论(0) 推荐(0)

1028. List Sorting (25)
摘要:题目如下: Excel can sort records according to any column. Now you are supposed to imitate this function. Input Each input file contains one test case.... 阅读全文

posted @ 2015-06-05 15:52 张大大123 阅读(171) 评论(0) 推荐(0)

1027. Colors in Mars (20)
摘要:题目如下: People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit nu... 阅读全文

posted @ 2015-06-05 15:42 张大大123 阅读(122) 评论(0) 推荐(0)

在 Mac OS X 10.10 安装 pyenv 的一个小坑
摘要:小记一下。 因为全面转向 Python 3.4 作为主力开发版本,但是手上的 Mac OS X 和服务器上用的都是 Python 2.7,所以需要安装 pyenv。 按其 github 页面的说明,使用 homebrew 安装brew updatebrew install pyen... 阅读全文

posted @ 2015-06-03 13:08 张大大123 阅读(197) 评论(0) 推荐(0)

使用C++的string实现高精度加法运算
摘要:对于超大数字的运算,用long long int仍然不能解决,这时候就需要考虑通过模拟运算和数组存储来实现高精度运算。 本文讨论借助C++的string来实现高精度的运算。 首先输入的量直接存储为string,设为s1和s2。 接下来设计一个反转函数,用于把整个字符串反转(为了方便后续计算)。 ... 阅读全文

posted @ 2015-06-02 20:58 张大大123 阅读(679) 评论(0) 推荐(0)

1025. PAT Ranking (25)
摘要:题目如下: Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed ... 阅读全文

posted @ 2015-06-02 20:38 张大大123 阅读(158) 评论(0) 推荐(0)

判断无向图是否有环路的方法 -并查集 -BFS
摘要:可以利用并查集或者带颜色标记的BFS(来自算法导论)判断。 首先介绍第一种,用并查集来判断: 首先初始化所有元素的根为-1,-1代表根节点,接下来对于图中的每一条边(v1,v2)都并入集合,并入的方式为查找v1和v2的根节点,然后让v2的根节点作为v1的根节点,查找根节点的过程为:如果当前的结点... 阅读全文

posted @ 2015-06-01 16:14 张大大123 阅读(2587) 评论(0) 推荐(0)

1021. Deepest Root (25) -并查集判树 -BFS求深度
摘要:题目如下: A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed t... 阅读全文

posted @ 2015-06-01 15:01 张大大123 阅读(298) 评论(0) 推荐(0)

导航

点击右上角即可分享
微信分享提示