ising model

Does anyone has any prog (in C) which calculates the Hamiltonian considering a unidimensional array of spins, positive J representing a ferromagnetic model with J=1, 0.