📅  最后修改于: 2022-03-11 14:59:42.485000             🧑  作者: Mango
//rounds a number to the closest odd value
// sudo code----------------------------------------
x = 2 * floor (x/2) + 1
//for example 2.1 -> 3 , 3.9 -> 3 , 4.1 -> 5 etc...
//C#------------------------------------------------
Using System;
double x = 2.1;
x = 2 * Math.Floor(x/2) + 1; // x is now 3
Console.Write(x);