摘要: 在将VS中的程序移植到ubuntu中出现的一个问题,主要原因是在vs中默认的主函数写成int _tmain(), 而在gcc编译时要找的是int main().改过来就可以了。 阅读全文
posted @ 2017-08-25 10:19 司马_羽鹤 阅读(4287) 评论(0) 推荐(0) 编辑
摘要: 通过简单的程序设计熟练CUDA的使用步骤 下面是cuda代码及相关注释 编译和执行 当设定num数量少时cpu的计算耗时会比gpu短,但是随着num的增加,cpu的耗时会成比例增加,但是gpu耗时基本没有变化。 阅读全文
posted @ 2017-08-10 21:54 司马_羽鹤 阅读(1526) 评论(0) 推荐(0) 编辑
摘要: 任务说明:有36篇文档,现在要读入,并统计词频,字典长度25,希望能够比较串并行读写操作的时间差距。 串行读入并统计词频 这里讨论并行有三种思路:一,按照文档序号进行分组读入统计等操作;二,在文档内按单词数目分组进行统计;三,将统计与读写操作并行处理。 针对第一种思路,使用openmp做多线程处理: 阅读全文
posted @ 2017-07-19 21:43 司马_羽鹤 阅读(1043) 评论(0) 推荐(0) 编辑
摘要: 学习g++能够读取什么格式的txt文件。 读基本指令: >sprintf(filename, "doc_%d.txt", d); >fileptr = fopen(filename, "r"); >while ((fscanf(fileptr, ... 阅读全文
posted @ 2017-07-18 22:59 司马_羽鹤 阅读(523) 评论(0) 推荐(0) 编辑
摘要: 目的:有一段代码要进行几个人同时维护,但是传来传去不方便,所以希望在github上实现,前提是每台机器都有git 在github 上新建一个项目 然后会看到,大体上就按这执行就可以 在Windows系统中,使用gitshell,cd到一个相应的文件夹下,然后 运行git init和git clone两条命令: 在相应的位置看到了克隆的版本,然后尝试在新的文件夹中添加文件或者代码。 ... 阅读全文
posted @ 2017-07-17 22:48 司马_羽鹤 阅读(323) 评论(0) 推荐(1) 编辑
摘要: Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, 阅读全文
posted @ 2017-05-10 16:09 司马_羽鹤 阅读(161) 评论(0) 推荐(0) 编辑
摘要: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2017-05-04 15:32 司马_羽鹤 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x. 注:这里的输入输出都是整数说明不会出现 sqrt(7)这种情况,思路一就是应用二分法进行查找。每次给出中间值,然后比对cur的平方与目标值的大小。需 阅读全文
posted @ 2017-04-24 16:22 司马_羽鹤 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 38. Count and Say The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" o 阅读全文
posted @ 2016-12-25 18:46 司马_羽鹤 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 27. Remove Element Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for 阅读全文
posted @ 2016-12-16 10:30 司马_羽鹤 阅读(125) 评论(0) 推荐(0) 编辑