Computation offloading is a hot topic to minimizing the energy consumption in cloud-assisted mobile computing. However, the assumption is that the mobile devices must have network connectivity to cloud. In this paper, we propose an adaptive computation offloading system, called mobile cloud with smart offloading system (MCSOS), which allows that the resource-poor mobile devices could offload its computation to nearby devices which have idle resources. Because there are different computation-offloading scenarios, the total energy consumption is influenced by factors, such as the energy-efficiency of computation and communication of these devices and the transmission distances among these devices. Therefore, the MCSOS is proposed to solve the optimization problem with objective of minimizing the total energy consumption under such ad hoc computation offloading. According to the simulation results, it shows that the MCSOS could improve the energy efficiency from 7% to 61% in different simulation cases.