第二题python实现,大家看看: https://blog.csdn.net/Qianzhen_Sun/article/details/108247490