The algorithm for a class of optimal control problem where the state variables are the weak solution of an elliptic partial differential equation is studied.Under certain conditions,by using a series of transformations,the solution of optimal control problem is transformed into solving a nonsmooth operator equation.A smoothing function which can be approximated by NCP-function is given and the smoothing Newton method is applied to resolve this nonsmooth operator equation.The estimated error is shown.