Archive for April, 2009

April 25, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
bool fun(unsigned n)
{
    assert(n >0); //乘方不为正
    if (!(n & (n-1))) //n的二进制只有一个1,即n==2^m;
    {
        int offset = 0;//"1"位的偏移量
        while (n != 1)
        {
            n>>=1;
            offset++;
         }
         if (offset && !(offset&1))//偏移量为偶数,即 n == 2^(2*m),亦即n == 4^m;
        {
            return true;
         }
      }
      return false;
}
Tags: . 7 views

某输水管线是利用114米地面落差有压、重力流输水工程。管径2.2米,管线长度176公里,地面高程变化很大。
当输水管线建成后,首次通水时,为了防止水流速波动产生水击破坏管线,只能以每秒0.6立方米的流速由某水库向管线内灌水。

Tags: . 33 views
April 23, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
 
using namespace std;
//! declaration and implementation of class Matrix
class Matrix
{
	public:
		Matrix(int n = 2);
		Matrix(const Matrix& rf);
		int& operator [][](int x, int y);//! operator[][]
		int& operator [][](int x, int y) const;//! operator[][]const
		Matrix& operator *=(Matrix& rt);//! operator *=
	private:
		int *p_Matrix;//! pointer to the 2D array
		int m_n;//! dimension of the matrix
};
Tags: ,. 8 views
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
        ORG 8000H                    ; position the localtion of the beginning of the commands
        LJMP START                  ; jump to the user's commands 
        ORG 8100H                    ; position the localtion of the program
START:	MOV R0, #08H       ; times of right or left shifts
	MOV A, #0FEH               ; set LED which is lighten
	JNB P3.2, LOOP_L           ; watch the switch which controls the shift direction
LOOP_R:	RR A                    ; branch 1: right shift
	MOV P1, A
	LCALL DELAY                 ; delay so that we can notice the flickering
	DJNZ R0, LOOP_R
	SJMP START
LOOP_L:	RL A                     ; branch 1: right shift
	MOV P1, A
	LCALL DELAY
	DJNZ R0, LOOP_L
	SJMP START	 
 
DELAY:  PUSH 06H                   ; subProgram impliments delaying
	PUSH 07H
	MOV R7, #0FFH
LABEL1:
	MOV R6, #0FFH
LABEL2:
	DJNZ R6, $
	DJNZ R7, LABEL1
	POP 07H
	POP 06H
	RET
	END
Tags: . 18 views
April 22, 2009

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <cmath>
 
using namespace std;
double Sqrt(double x);
int main()
{
	double x;
	cin>>x;
	cout<<Sqrt(x)<<endl;
	return 0;
}
 
double Sqrt(double x)
{
	const double eps = 1E-6;
	double x0 = x / 2, x1 = (x0 + x / x0) / 2;
	while(fabs(x1 - x0) > eps)
	{
		x0 = x1;
		x1 = (x0 + x / x0) / 2;
	}
	return x0;
}
Tags: ,. 7 views
April 19, 2009

与Windows将硬盘看做“C盘”、“D盘”几个独立的分区不同,Linux将整个文件系统看做一棵树,这棵树的树根叫做根文件系统,用/表示。各个分区通过“挂载”(mount)以文件夹的形式访问。在/中的文件夹很多,本文介绍常见文件夹的意义。Linux的目录结构确实比较复杂,但设置合理、层次鲜明。本文以FHS 2.3[1]为例进行介绍。

Tags: . 31 views
  • .gz
  • 解压1:gunzip FileName.gz
    解压2:gzip -d FileName.gz
    压缩:gzip FileName

  • .tar.gz
  • 解压:tar zxvf FileName.tar.gz
    压缩:tar zcvf FileName.tar.gz DirName


    • .bz2
    • 解压1:bzip2 -d FileName.bz2
      解压2:bunzip2 FileName.bz2
      压缩: bzip2 -z FileName

Tags: . 53 views
1
2
3
4
5
6
7
8
9
10
dpkg -i package.deb 安装包
dpkg -r package 删除包
dpkg -P package 删除包(包括配置文件)
dpkg -L package 列出与该包关联的文件
dpkg -l package 显示该包的版本
dpkg –unpack package.deb 解开 deb 包的内容
dpkg -S keyword 搜索所属的包内容
dpkg -l 列出当前已安装的包
dpkg -c package.deb 列出 deb 包的内容
dpkg –configure package 配置包
Tags: . 81 views

For the safe of convenience, we firstly install the compile environment of stardict version 2.4.

# apt-get build-dep stardict

Then, we should clear up the previous stardict, if you installed it. (the dicts will be saved).

# apt-get remove --purge stardict stardict-common

Other packages that are not necessary, maybe.

# apt-get install libenchant-dev libgucharmap-dev gucharmap libespeak-dev
Tags: . 18 views
1
2
3
4
5
6
/*
 *Filename:		tri_Diagonal
 *Description	a solution to the tri-diagonal linear formulation
 *author:		HouFenglin@物理0605/DUT
 *Time:			13/04/2009
 */
Tags: . 20 views
Page 3 of 41234