In cellular networks, device-to-device communications can increase the spectrum efficiency, but some conventional schemes only consider uplink or downlink resource allocation. In this paper, we propose the joint uplink and downlink resource allocation scheme which maximizes the system capacity and guarantees the signal-to-noise-and-interference ratio of both cellular users and device-to-device pairs. The optimization problem is formulated as a mixed integer nonlinear problem that is usually NP hard. To achieve the reasonable resource allocation, the optimization problem is divided into two sub-problems including power allocation and channel assignment. It is proved that the objective function of power control is a convex function, in which the optimal transmission power can be obtained. The Hungarian algorithm is developed to achieve joint uplink and downlink channel assignment. The proposed scheme can improve the system capacity performance and increase the spectrum efficiency. Numerical results reveal that the performance of the proposed scheme of jointly uplink and downlink is better than that of the schemes for independent allocation.