1. synchronized
If two threads are using the same function( here we use output to print out string) of another instance, if we want to make sure that these two threads are not disturbing each other.
...
分类:
其他好文 时间:
2014-05-15 11:14:14
阅读次数:
389
快速排序最坏情况下时间复杂度是O(n*n),但是它平均时间复杂度是O(N*logn),并且常数因子很小,可实现就地排序,所以被作为内排序的常用排序方法.
#include
using namespace std;
void swap(int &i,int &j)
{
int temp=i;
i=j;
j=temp;
}
int partition(int *vector...
分类:
其他好文 时间:
2014-05-15 06:05:35
阅读次数:
254
//拷贝构造函数,什么时候算是 “合适的时候”,才会合成呢~~~
#include
using namespace std;
class A
{
public:
A(char *_str):str(_str),x(0){}
//A(const A&a){cout
//如果没有定义的话,对于类A来说,编译器依然不会合成,因为此时的对象之间的...
分类:
其他好文 时间:
2014-05-15 05:11:13
阅读次数:
334
/*
* hdu How many prime numbers
* date 2014/5/13
* state AC
*/
#include
#include
#include
using namespace std;
bool isPrime(int x)
{
int sqr=sqrt(x*1.0);
for(int i=2;i<=sqr;i++)
{...
分类:
其他好文 时间:
2014-05-15 05:07:18
阅读次数:
261
#include
#include
using namespace std;
class Teacher
{
public:
Teacher(string nam,int ag,char s,string ad,int num,string t)
{
name=nam;
age=ag;
sex=s;
...
分类:
其他好文 时间:
2014-05-15 04:32:56
阅读次数:
262
题目来源:UVa 10308 Roads in the North
题意:求距离最远的2点之间的距离
思路:裸的树的直径 或者树形DP
#include
#include
#include
using namespace std;
const int maxn = 100010;
struct node
{
int to, w;
node(){}
node(int to, int...
分类:
其他好文 时间:
2014-05-15 03:37:18
阅读次数:
295
#include
#include
#include
#include
#include
#include
using namespace std;
struct ssss
{
ssss *c[26];
int n,v;
}*s;
void insert(char *str,int v)
{
int i,j,k,l;
ssss *p,*q;
p=...
分类:
其他好文 时间:
2014-05-14 15:06:54
阅读次数:
357
/*
* hdu 最小公倍数
* date 2014/5/13
* state AC
*/
#include
using namespace std;
int gcd(int x,int y)
{
while(x!=y)
{
if(x>y)x=x-y;
else y=y-x;
}
return x;
}
int main()
...
分类:
其他好文 时间:
2014-05-14 14:29:59
阅读次数:
225
#include using namespace std;int
GreatestCommonDivisor(int m,int n) //辗转相除法求最大公约数{ int r; do { r = m % n; m = n;
...
分类:
编程语言 时间:
2014-05-14 11:18:00
阅读次数:
675
这是微软官方教程Getting Started with Entity Framework 6
Code First using MVC 5 系列的翻译,这里是第十篇:为ASP.NET MVC应用程序处理并发原文:Handling Concurrency
with the Entity Framew...
分类:
Web程序 时间:
2014-05-14 10:39:02
阅读次数:
695