面试题之--实现取余
程序员文章站
2023-01-19 12:53:17
思路,for循环,if循环 用乘法来判断, ......
def quyu(shu,chushu): if shu==chushu: print('余数是0') elif shu<chushu: print('余数是:%s'%shu) elif chushu==0: print('除数不能为0') else: for i in range(0,shu): if shu-i*chushu>chushu: i+=1 elif shu-i*chushu==chushu: print('余数是0') break elif shu-i*chushu==0: print('余数是0') break else: print((shu-i*chushu)) break quyu(10,3)
思路,for循环,if循环 用乘法来判断,
上一篇: 爆笑奇葩,笑都笑不过来哇!
下一篇: 爆冷的二货男和犀利女