571113171923293137414347535961677173798389971011031071091131271311371391491511571631671731791811911931971992112232272292332392412512572632692712772812832933073113133173313373473493533593673733793833893974014094194214314334394434494574614634674794874914995035095215235415475575635695715775875935996016
571113171923293137414347535961677173798389971011031071091131271311371391491511571631671731791811911931971992112232272292332392412512572632692712772812832933073113133173313373473493533593673733793833893974014094194214314334394434494574614634674794874914995035095215235415475575635695715775875935996016
现在有一个需求:针对一个答题统计,需要统计近5次的错误次数.思路是,使用数表去储存这5次错误次数,然后统计数表现在有一个5个元素的数表error_last_5_times={1,0,1,0,1}其中1表示正确,0表示错误这里有两种统计方法:--方法1:使用迭代数表来统计error_last_5_times={1,0,1,0,1}total1=function(error_last_5_times)localwrong_times=0fori=1,5doiferror_last_5_times[i]==0thenwrong_times=wrong_times+1endendreturnwrong
现在有一个需求:针对一个答题统计,需要统计近5次的错误次数.思路是,使用数表去储存这5次错误次数,然后统计数表现在有一个5个元素的数表error_last_5_times={1,0,1,0,1}其中1表示正确,0表示错误这里有两种统计方法:--方法1:使用迭代数表来统计error_last_5_times={1,0,1,0,1}total1=function(error_last_5_times)localwrong_times=0fori=1,5doiferror_last_5_times[i]==0thenwrong_times=wrong_times+1endendreturnwrong