A numerical method for solving viscous shock-layer equations