利用位元運算來判斷奇偶數
if( (value & 1) == 0 )
cout << "偶數";
else
cout << "奇數";
2012年10月16日 星期二
2012年8月20日 星期一
2012年7月3日 星期二
C/C++ 中的括號
在 C語言中的括號分別化表
{ } 大括號表示函式本體的開始與結束
( ) 小括號在函式的宣告中使用
大括號的另類用法,指定了變數的作用範圍,在大括號中的變數都是局部變數,有效區域只在大括號中有效。有效利用這個特性可以使程式簡單明白。
int a = 5;
{
int a = 2;
printf("Here a=%d!!\n", a);
}
printf(" a=%d!!\n", a);
{ } 大括號表示函式本體的開始與結束
( ) 小括號在函式的宣告中使用
大括號的另類用法,指定了變數的作用範圍,在大括號中的變數都是局部變數,有效區域只在大括號中有效。有效利用這個特性可以使程式簡單明白。
int a = 5;
{
int a = 2;
printf("Here a=%d!!\n", a);
}
printf(" a=%d!!\n", a);
2012年5月29日 星期二
NFSv4 設定
最近在設定CentOS 6 的時候發現, NFS default 是用version 4. 不察之下發現設不起來 ><
底下是NFSv4 的設定
CentOS 6時,由於NFS為NFSv4,需多設定一個檔案為/etc/idmapd.conf 還有必須啟動rpcidmapd服務
Head Node
#### vi /etc/idmapd.conf
[General]
Verbosity = 1 #主要更改
# The following should be set to the local NFSv4 domain name
# The default is the host's DNS domain name.
Domain = snowfox #主要更改
.
. (略)
.
#Local-Realms =
[Mapping]
#Nobody-User = nobody
#Nobody-Group = nobody
然後 將rpcidmapd服務開啟 service rpcidmapd start chkconfig rpcidmapd --level 345 on
2012年5月28日 星期一
安裝 wxPython
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
yum install wxPython.x86_64 wxPython-devel.x86_64
Dependencies Resolved
==================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================
Installing:
wxPython x86_64 2.8.9.1-1.el5.rf dag 22 M
wxPython-devel x86_64 2.8.9.1-1.el5.rf dag 479 k
Installing for dependencies:
wxGTK x86_64 2.8.10-1.el5.rf dag 27 M
wxGTK-devel x86_64 2.8.10-1.el5.rf dag 1.1 M
訂閱:
文章 (Atom)