The purpose of this paper is to determine a shape of a body which minimizes fluid force on a surface of a two dimensional elliptical cylinder and a three dimensional disk located in the compressible viscous flow expressed by the Navier-Stokes equations. The formulation to pursue an optimal shape is based on the optimal control theory. The optimal state is defined that a performance function, which consists of integration of a square sum of fluid forces, is minimized. The compressible Navier-Stokes equations are treated as constrained equations. A gradient of the performance function is computed by adjoint variables. The weighted gradient method is used as a minimization algorithm. A volume of the body is assumed to be constant. For the discretization of basic and adjoint equations, the mixed interpolation method based on the bubble function interpolation presented previously by the authors is employed. The structured mesh around the surface is introduced and smoothing is employed for the gradient. As numerical studies, a shape optimization of an elliptical cylinder in a uniform flow field is carried out. As an initial shape, the body is assumed as an ellipse. The shape is updated minimizing the fluid forces on the surface. The stable optimal shape determination of a body in the compressible flows is obtained by the presented method. Finally, several three dimensional disks based on the final shape obtained in two dimension are calculated in the compressible viscous flows.