近來 Windows 7 已經越來越普遍, 之前使用 FreeNAS 架設網域伺服器的用戶端也開始升級使用 Windows 7, 而用戶端為 Windows 7 時要如何 Join 到使用 Samba 的 PDC 網域 ? 必須要修改 Windows 7 的 regedit 登入檔 , 方式如下。
(1) 增加 DomainCompatibilityMode 及 DNSNameResolutionRequired 兩個 DWORD 值一個為1另一個為0
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters]
“DomainCompatibilityMode”=dword:00000001
“DNSNameResolutionRequired”=dword:00000000
(2) 改變 RequireSignOnSeal 及 RequireStrongKey 的值由 1 變 0
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Netlogon\Parameters]
“RequireSignOnSeal”=dword:00000000
“RequireStrongKey”=dword:00000000
Reference :
http://www.1stbyte.com/2009/05/31/join-windows-7-to-samba-pdc
2010/02/23
[ FBSD ] How to Join Windows 7 to Samba PDC
2009/11/17
[ C/C++ ] Matrix Multiplication by Pointers
矩陣乘法 Matrix Multiplication
// matrixMultiplication.cpp
//
// It's a 2x3 matrices program of matrix multiplication using pointers in C++
//
// Console-based
// Retruns real as well as comples roots.
// Author Jim.lin 2009
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int i, j, k, sum;
// matrix space
const int ROW_A = 2, COL_A = 3;
const int ROW_B = 3, COL_B = 2;
// define matrix value
int a[ROW_A][COL_A] = {{1,3,1},{1,2,3}};
int b[ROW_B][COL_B] = {{1,3},{3,5},{3,3}};
int c[ROW_A][COL_B];
// define 3 pointers to first address
int *pa, *pb, *pc;
pa = &a[0][0];
pb = &b[0][0];
pc = &c[0][0];
// caclulation
for ( i=0; i<ROW_A; ++i ) {
for (j=0; j<COL_B; ++j) {
sum = 0;
for( k=0; k<COL_A; ++k ) {
sum += *(pa+i*COL_A+k) * *(pb+k*COL_B+j);
}
*(pc+i*COL_B+j) = sum;
}
}
// print matrix a
for ( i=0; i<ROW_A; ++i) {
for (j=0; j<COL_A; ++j) {
cout << *(pa+i*COL_A+j) << " ";
}
cout << endl;
}
cout << '\n';
// print matrix b
for (i=0; i<ROW_B; ++i) {
for (j=0; j<COL_B; ++j) {
cout << *(pb+i*COL_B+j) << " ";
}
cout << endl;
}
cout << '\n';
//print multiple matrix c
for (i=0; i<ROW_A; ++i) {
for (j=0; j<COL_B; ++j) {
cout << *(pc+i*COL_B+j) << " ";
}
cout << endl;
}
return 0;
}
Ref.
http://en.wikipedia.org/wiki/Matrix_multiplication
2009/11/10
[ C/C++ ] Insertion Sort by C++
Insertion sort is an elementary sorting algorithm. The time complexity of Θ(n2).
// insertSort.cpp
//
// Sorting Algorithm (insertion sort) .
//
// Console-based
// Retruns real as well as comples roots.
// Author Jim.lin 2009
#include <iostream>
#include <vector>
using namespace std;
int main()
{
unsigned int i, j, k, tmp;
cout << "Please Input a Number :";
cin >> k;
vector<int> data(k); //定義一個整數型態k大小的向量陣列
cout << "Please Input " << k << " Number :";
for ( i=0; i < data.size(); ++i )
cin >> data[i];
// Begin Sorting
for ( i=1; i < data.size(); ++i )
{
for (j=i; j>0; --j)
{
if (data[j] >= data[j-1] )
break;
else
{
tmp = data[j];
data[j] = data[j-1];
data[j-1] = tmp;
}
}
}
// Output Sorted
cout << "\n Sorted Resulte:";
for ( i=0; i<data.size(); ++i )
cout << data[i] << " ";
cout << endl;
return 0;
}
2009/11/02
[ C/C++ ] Transfer to Binary
將輸入整數值轉換成二進位數值
// Binary.cpp
//
// transfer to binary
//
// Console-based
// Author Jim.lin 2009
#include <iostream>
using namespace std;
int main()
{
int N;
int v = 1;
cin >> N;
while(v <= N/2)
v = 2*v; // 此時 v 值為 <= N 的最大次方
int n = N;
while(v > 0)
{
if (n < v) { cout << "0"; }
else { cout << "1"; n -= v; }
v = v/2;
}
}
2009/10/29
[ C/C++ ] Powers Of Two by C++
使用 C++ 輸出 2 的次方值 Power Of Two
// powersOfTwo.cpp
//
// Powers of Two, 2^i
//
// Console-based
// Author Jim.lin 2009
#include <iostream>
using namespace std;
int main()
{
int N;
int v = 1;
int i = 0;
cin >> N;
while(i <= N)
{
cout << i << " " << v << endl;
v = 2 * v;
i = i + 1;
}
}
2009/10/25
[ C/C++ ] Leap Year Check
閏年定義(leap year or intercalary year) : 四年一閏,百年不閏,四百年閏,四千年閏
英文字典 leap year ?
A leap year is a year which has 366 days. The extra day is the 29th February. There is a leap year every four years.
// leapyear.cpp
//
// This program to determine leap year.
//
// Console-based
// Retruns real as well as comples roots.
// Author Jim.lin 2009
#include <iostream>
using namespace std;
int main()
{
int year;
cin >> year;
if(( year%4==0 && year%100!=0 ) || year%400==0 )
cout << "Leap Year ";
else
cout << "Not Leap Year ";
return 0;
}
Ref.
By Google.
2009/10/15
[ C/C++ ] Quadratic by C++
使用 C++ 解一元二次方程式
// quadratic.cpp
//
// This program solves a quadratic equation in standard form.
// ax^2 + bx + c = 0
//
// Console-based
// Retruns real as well as comples roots.
// Author Jim.lin 2009
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
double a,b,c;
double x1,x2;
double i;
// main function
int main()
{
cout<<"Please Input Number a,b,c:\n";
cin>>a>>b>>c;
i=sqrt(b*b-4*a*c);
if(i<0)
cout<<"This is imaginary roots";
else if(i==0)
{
x1=-b/(2*a);
cout<<"The quadratic equation has one root" << x1 << endl;
}
else
{
x1=(-b+i)/(2*a);
x2=(-b-i)/(2*a);
cout<<"The quadratic equation has two roots" << endl;
cout<<"x1=" << x1 << " x2=" << x2 << endl;
}
}
Best Code :
http://jblanco_60.tripod.com/c_pp_quadratic.html
訂閱:
文章 (Atom)

