C#
using System; public class Evaporator { public static int evaporator(double content, double evap_per_day, double threshold) { return (int)Math.Ceiling(Math.Log(threshold / 100.0) / Math.Log(1.0 - evap_per_day / 100.0)); } } /* 1,Math.Ceilling(向上取整) 2,Math.Log 取对数 lne=1 http://www.cnblogs.com/yuruolt/p/4561838.html(【Math类】常用函数) */ public class Evaporator { public static int evaporator(double content, double evap_per_day, double threshold) { content = 100.0; int days = 0; while (content > threshold) { content -= content * evap_per_day * .01; days += 1; } //每天都比较下总内容和每天要散发出的,需要22天才能挥发完。 return days; } }
时间: 2024-11-10 17:40:45