现在位置: 首页 > pendulum发表的所有文章
  • 09月
  • 27日
综合 ⁄ 共 12832字 评论关闭
原文出处: ifeve 寻寒(@小疯子诗人)    写在前面的话 由于之前工作中的疏忽,在使用Java多线程并发的时候出了问题,遂决心全面学习并发相关知识。写作本文的意图只是希望在写作过程中把想不清楚或是一时无法掌握的地方反复揣摩记录下来。写作本文参考的各种资料较多,抱歉的是文末的参考文献中对一些叫不上名字或没有出处的资料文献并未列举出来。由于本人是初入职场的菜鸟,更是并发的门外汉,文中关于并发以及其他软硬件、程序设计语言的论据也许不够客观甚至不够正确。对于这些问题还请大家不吝指教,欢迎讨论,望共同学习......
阅读全文
  • 05月
  • 24日
综合 ⁄ 共 1532字 评论关闭
计算器的雏形代码: package com.tedneward.calcdsl { private[calcdsl] abstract class Expr private[calcdsl] case class Variable(name : String) extends Expr private[calcdsl] case class Number(value : Double) extends Expr private[calcdsl] case class UnaryOp(operator : String, arg : Expr) extends Expr private[calcdsl] case class BinaryOp(operator : String, left : Expr, right : Expr) extends Expr object Calc { /** * Function to simplify (a la mathematic terms) ex......
阅读全文
  • 04月
  • 20日
综合 ⁄ 共 1902字 评论关闭
转载请注明出处:http://blog.csdn.net/lhy_ycu/article/details/39759199 装饰者(Decorator)模式:动态地将责任附加到对象上,若要扩展功能,装饰者提供了比继承更具有弹性的替代方案。对于装饰者模式,它其实是一种包装,所以我更愿意称它为一种包装。像咱们以前经常使用的Java里面的IO流就用到了装饰者模式。比如:BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file1)));这里file1为目标对象,而像BufferedReader、InputStreamReader就可以称之为包装类。下面举例说明: 一、UML模型图......
阅读全文
  • 02月
  • 24日
综合 ⁄ 共 1031字 评论关闭
题目链接~~> 做题感悟:刚开始做时完全没有思路,甚至题意都不怎么清楚,但是当下定决心解决它时就很容易解决了。 解题思路:二分:算出最小份蛋糕的体积和最大份蛋糕的体积,然后枚举每一种情况看是否满足(让esp = 1e - 7 即可,精确到 8 会超时)。 代码: #include<stdio.h> #include<iostream> #include<map> #include<stack> #include<string> #include<string.h> #include<stdlib.h> #include<math.h> #include<vector> #include<queue> #include<algor......
阅读全文
  • 12月
  • 21日
综合 ⁄ 共 680字 评论关闭
题意: 给一串-和o组成的字符串,你可以把“-oo"变成”o--",可以把“oo-”变成“--o",问最后最少有多少个o. 状态压缩 ,记忆化搜索 code: #include <stdio.h> #include <string.h> #define len 12 #define min(a,b) (((a)<(b)) ?(a):(b)) int d[1<<13]; int dp(int n) { int i, t; if(d[n]!=-1) return d[n]; d[n] = 0; for(i=0; i<len; i++) if(n&(1<<i)) d[n]++; for(i=0; i<len-2; i++) { t = n; if( (t&(1<<i)) &......
阅读全文
  • 08月
  • 21日
综合 ⁄ 共 60字 评论关闭
http://blog.csdn.net/lyq8479/article/details/9841371  柳峰老师的博客
阅读全文
  • 05月
  • 13日
综合 ⁄ 共 4048字 评论关闭
zz http://linux.frank4dd.com/en/man3/pthread_setaffinity_np.htm http://www.daemon-systems.org/man/pthread_getaffinity_np.3.html pthread_setaffinity_np and sched_setaffinity 样例程序 NAME pthread_setaffinity_np, pthread_getaffinity_np - set/getCPU affinity of a thread SYNOPSIS #define _GNU_SOURCE #include <pthread.h> int pthread_setaffinity_np(pthread_t thread, size_tcpusetsize, const cpu_set_t *cpuset); int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_se......
阅读全文
  • 04月
  • 29日
综合 ⁄ 共 1540字 评论关闭
/* 通过这题对分治、递归均有了更深一层的理解。 花在理解和coding上的时间值得了 */ #include <iostream> #include <cmath> #include <algorithm> using namespace std; typedef struct Node { double x, y; }Node; Node array[100010]; Node a[100010]; const int inff = 65535; bool cmpx(Node a, Node b) { return a.x < b.x; } bool cmpy(Node a, Node b) { return a.y < b.y; } double Euc(Node a, Node b) { return sqrt( (a.x - b.x) * (a.x- b.x) + (a.y - b.y) * (a.y - b.y)); } ......
阅读全文
  • 04月
  • 24日
综合 ⁄ 共 1976字 评论关闭
文章目录 Sample1.in: Sample1.out Sample2.in Sample2.out Sample3.in Problem Description 即使czhou没有派出最强篮球阵容,机房篮球队还是暴虐了校篮球队。为了不打击校篮球队信心,czhou决定改变训练后的活动。近来,江大掌门的徒弟徒孙们纷纷事业有成,回到母校为机房捐钱捐物。财大气粗的机房组收回了五层六层的所有教室。Czhou决定将六层的教室改造为智能密室逃脱活动室。 每天傍晚,神牛们可以依次逐个进入游玩。我们简单的将教室分割为n*n个房间,K是你初始所在房......
阅读全文
  • 04月
  • 14日
综合 ⁄ 共 5015字 评论关闭
from: http://www.cnblogs.com/turingbooks/archive/2012/03/06/2382229.html 程序员编程生产力相差10倍意味着什么? 在软件工程研究中,被验证得最多的结论就是对于同等经验的两个不同程序员,在效率和质量上可能会有10倍的差距。研究人员还发现,这种差距也适用于团队级别上,也就是说在同一行业内的不同的团队也是如此。 软件开发中的个人效率的变化 首先发现不同人在编程生产力上的巨大差距的研究,是1960年由Sackman、Erikson以及Grant三个人完成的。他们研究了工作经验平 均在7年的专业程序员,并发现最好和最差......
阅读全文
  • 04月
  • 02日
综合 ⁄ 共 545字 评论关闭
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2094 //拓扑排序 /* 网上看到的一个比较好的方法,使用map,set处理。 利用set建立点集,用map映射形成边,用输的指向赢的 A <- B 由于题目是求产生冠军,只需要有向图只有一个根就可以了,即遍历set点集合时,查看是否有后继,且唯一 */ #include <iostream> #include <map> #include <set> #include <string> using namespace std; int main () { set<string> s; set<string>::iterator it; map<string, string> m; str......
阅读全文
  • 03月
  • 19日
综合 ⁄ 共 770字 评论关闭
添加,刪除字段 如果要在数据表中添加一个字段,应该如何表示呢?下面就为您介绍表添加字段的SQL语句的写法,希望可以让您对SQL语句有更深的认识。 通用式: alter table [表名] add [字段名] 字段属性 default 缺省值 default 是可选参数 增加字段:  alter table [表名] add 字段名 smallint default 0 增加数字字段,整型,缺省值为0 alter table [表名] add 字段名 intdefault 0 增加数字字段,长整型,缺省值为0 alter table [表名] add 字段名 singledefault 0 增加数字字段,单精度型,缺省值为0 alter table [表名] ......
阅读全文