现在位置: 首页 > WrefeliAnnern发表的所有文章
  • 04月
  • 21日
综合 ⁄ 共 1351字 评论关闭
// 零长数组:用于结构体的末尾,本身不占用空间,因此对sizeof没有影响,但有利于实现可变程度的数组 // 如果有点编译器不支持,为了通用型,可以换成1长数组 #include <stdio.h> #include <stdlib.h> // 结构体定义 struct Item1 { int type; int len; unsigned char data[0]; // 或: // unsigned char data[]; }; int main() { //1 //struct Item1 in1; //printf("sizeof(in1): %d\n",sizeof(in1)); //2 //char ca1[100]; //struct Item1 *it1; //int i; //it1=(stru......
阅读全文
  • 03月
  • 20日
综合 ⁄ 共 1008字 评论关闭
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <pthread.h> void *thread_function(void *arg); char message[] = "Hello World"; int main() { int res; pthread_t a_thread; void *thread_result; res = pthread_create(&a_thread, NULL, thread_function, (void *)message); if (res != 0) { perror("Thread creation failed"); exit(EXIT_FAILURE); } printf("Waiting for thread to finish...\n"); res = pthread_j......
阅读全文
  • 02月
  • 24日
综合 ⁄ 共 559字 评论关闭
(1)NYOJ 69 数的长度 做题感悟: 这题是很久以前做的,今天又看了一下完全忘记当时是怎么做的了。。。。 解题思路:如果计算一个数 x 有几位,int(log10(x))+ 1 就是 x  的位数 。因此 n ! 的位数 log10(n !)= log10(1 * 2 * 3 *4 ……* n) = log10(1) + log10 (2) + log10(3) ……log10(n) .还有一种方法就是用斯特林公式。 (2)HDU 1060 Leftmost Digit 解题思路:1. a ^ ( n ) 的位数 num =log10( a ^ ( n ) ) 所以 10 ^ num = a ^ n ,假设 num = x (整数部分) + y (小数部分) ; 所以( 10 ^ x ) *( 10 ^ y ) =a ^ n ;所以 ......
阅读全文
  • 02月
  • 15日
综合 ⁄ 共 3049字 评论关闭
Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 38092    Accepted Submission(s): 12269 Problem Description In the modern time, Search engine came into the life of everybody like Google, Baidu, etc. Wiskey also wants to bring this feature to his image retrieval system. Every image have a long description, when users type some keywords to find the image, the system will match the keywords with description of image and ......
阅读全文
  • 05月
  • 26日
综合 ⁄ 共 5542字 评论关闭
继 性能分析工具之-- Eclipse Memory Analyzer tool(MAT)(一),性能分析工具之-- Eclipse Memory Analyzer tool(MAT)(二)两篇文章之后,接下来该讲述Perm gen引起的内存泄露问题的分析过程。 perm gen 我们在上2篇文章中知道,perm gen是个异类,里面存储了类和方法数据(与class loader有关)以及interned strings(字符串驻留)。在heap dump中没有包含太多的perm gen信息。那么我们就用这些少量的信息来解决问题吧。 看下面的代码,利用interned strings把perm gen撑破了。 /**  * OOMPermTest class  * @author rosen ......
阅读全文
  • 05月
  • 24日
综合 ⁄ 共 5377字 评论关闭
 Java容器类的用途是“保存对象”,分为两类:Map——存储“键值对”组成的对象;Collection——存储独立元素。Collection又可以分为List和Set两大块。List保持元素的顺序,而Set不能有重复的元素。      本文分析Set中最常用的HashSet类,并简单介绍和对比LinkedHashSet。      首先对Set接口进行简要的说明。       存入Set的每个元素必须是惟一的,因为Set不保存重复元素。加入Set的元素必须定义equals()方法以确保对象的唯一性。Set不保证维护元素的次序。Set与Collection有完全一样的接口。      在没有其他限制的情况下需要Set......
阅读全文
  • 04月
  • 20日
综合 ⁄ 共 322字 评论关闭
现将个人 整理如下, 请勿转载,未经许可使用。 1.每个进程用唯一的进程ID表示;        应用:利用进程ID作为名字的一部分来创建唯一的文件名; 2 .ID可以重用;       注意: 大多数unix采用 延迟重用 算法,使 新建进程的ID 不同于 最近终止进程的ID 3.    ID 为0,是 调度进程 [ 又叫 交换进程,swapper],内核的一部分,不执行磁盘上程序        ID为1 ,是 init进程,在 自举过程结束时由内核调用。此进程的程序文件旧版本是/etc/init, 新版本 是 /sbin/ init.  特征:不会终止,普通的用户进程但以超级用户特权运行       ......
阅读全文
  • 04月
  • 20日
综合 ⁄ 共 2631字 评论关闭
文章目录 什么是 html html 能做什么,怎么做 html 是什么:html标签 html 能做什么,怎么做: html 怎么运行:浏览器解析引擎和渲染引擎工作原理、http 协议 什么是 html html:hyper text markup language hyper:hyper = high + press + er = hi + p + er = hy + p + er = super 超、过  Html是超文本标记语言的简写,是最基础的网页语言,html 是在原来的文本上添加上标签作为标记使原来的文本有额外的功能。 Html是通过标签来定义的语言,代码都是由标签所组成。 H......
阅读全文
  • 02月
  • 03日
综合 ⁄ 共 1341字 评论关闭
关于协程的概念,其实由来已久,在介绍协程的概念之前先简单回顾下我们通常使用到的例程、线程等概念。 例程(Subroutine) 例程的概念类似于函数,但含义更为丰富一些。例程是某个系统对外提供的功能接口或服务的集合。比如操作系统的API、服务等就是例程;C语言运行时提供的标准库函数等也是例程。Pthreads库提供的一套线程相关的API也属于例程。通俗的理解,一个子例程就是一次子函数调用,只不过相对一般函数,例程的通用性和相对独立性都比较强。 协程(Coroutine) 协程,意思就是“协作的例程”(co-operative routines),最......
阅读全文
  • 01月
  • 13日
综合 ⁄ 共 1554字 评论关闭
B. Kolya and Tandem Repeat time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string. Then Borya came and said that the new string contained a tandem repeat of length l as a substring. How large could l be? See notes for definition of a tandem repeat. Input The first line......
阅读全文
  • 12月
  • 27日
综合 ⁄ 共 590字 评论关闭
链接: http://blog.csdn.net/renfufei/article/details/10210949 链接: http://www.tuicool.com/articles/QZBzAz script可以通过添加async或者defer属性来让脚本不必同步执行。html的版本html4.0中定义了defer;html5.0中定义了async;这将造成由于浏览器版本的不同而对其支持的程度不同;   两者的区别在于执行时的不同: async属性: 表示当前脚本不必等待其他脚本,也不阻塞文档呈现,属异步执行。但不能保证脚本按照它们在页面中出现的顺序执行。 defer属性: 让脚本在文档完全呈现之后再执行。延迟脚本会按照脚本原来在页......
阅读全文
这篇说说java.util.concurrent.atomic包里的类,总共12个,网上有很多文章解析这几个类,这里挑些重点说说。 这12个类可以分为三组: 1. 普通类型的原子变量 2. 数组类型的原子变量 3. 域更新器 普通类型的原子变量的6个, 1. 其中AtomicBoolean, AtomicInteger, AtomicLong, AtomicReference分别对应boolean, int,  long, object完成基本的原子操作 2. AtomicMarkableReference, AtomicStampedReference是AtomicReference的功能增强版本,前者可以把引用跟一个boolean绑定,后者可以把引用和一个int型的版本号绑定来完成时间戳......
阅读全文