Due to multiple D2D users and one cellular user sharing the same downlink channel resources in TDD systems, an algorithm of resource allocation based on grouping for D2D pairs is proposed to maximize the system throughput, which consists of three parts. This algorithm firstly determines the D2D groups number with the system channels number and the user grouping position centre in terms of the distance among the D2D pairs, and divides the remaining D2D pairs into corresponding groups according to its degree of effect on the communication outage probability of users within the same D2D group. Afterwards, by comparing the interference impact of D2D group on the cellular user, the matching algorithm is used to determine and share the corresponding cellular channel resource for D2D group. Finally, according to the different QOS of cellular users and D2D pairs, the D2D pairs with serious interference are deleted and the D2D pairs sharing the cellular channel resource are finally determined. Simulation results show that more D2D pairs can access to the system and the system throughput is improved by the proposed algorithm.