تابعی ایجاد کنید تا لیستی از درصدها را به معادل اعشاری آنها تبدیل کند.
نمونه ورودی و خروجی
ConvertToDecimal(["1%", "2%", "3%"]) ➞ [0.01, 0.02, 0.03]
ConvertToDecimal(["45%", "32%", "97%", "33%"]) ➞ [0.45, 0.32, 0.97, 0.33]
ConvertToDecimal(["33%", "98.1%", "56.44%", "100%"]) ➞ [0.33, 0.981, 0.5644, 1]
Assert.Equal(new decimal[] { 0.01m, 0.02m, 0.03m }, Backendbaz.ConvertToDecimal(new string[] { "1%", "2%", "3%" })); Assert.Equal(new decimal[] { 0.45m, 0.32m, 0.97m, 0.33m }, Backendbaz.ConvertToDecimal(new string[] { "45%", "32%", "97%", "33%" })); Assert.Equal(new decimal[] { 0.33m, 0.981m, 0.5644m, 1m }, Backendbaz.ConvertToDecimal(new string[] { "33%", "98.1%", "56.44%", "100%" }));
نظرات