Функция, возвращающая 8 вместо 5 ⇐ C#
-
Гость
Функция, возвращающая 8 вместо 5
I am trying to beat a Hacker Rank problem where I am required to count the number of lucky dates between two given dates. The date intervals are inclusive and accepted in this format
dd-MM-yyyy. You then form an integer out of that date and check whether it's divisible by four or seven and then it's a lucky date.
The code am running is below
static void Main(string[] args) { //user entered start date and end date sperated by a space var input = Console.ReadLine(); var date1 = input.Split(new char[]{' '})[0]; var date2 = input.Split(new char[]{' '})[1]; //Parse date objects out of the strings DateTime A = DateTime.Parse(date1); DateTime B = DateTime.Parse(date2); //initialize count of lucky dates int luckyDates = 0; //use while loop to iterate while (A
Источник: https://stackoverflow.com/questions/781 ... stead-of-5
I am trying to beat a Hacker Rank problem where I am required to count the number of lucky dates between two given dates. The date intervals are inclusive and accepted in this format
dd-MM-yyyy. You then form an integer out of that date and check whether it's divisible by four or seven and then it's a lucky date.
The code am running is below
static void Main(string[] args) { //user entered start date and end date sperated by a space var input = Console.ReadLine(); var date1 = input.Split(new char[]{' '})[0]; var date2 = input.Split(new char[]{' '})[1]; //Parse date objects out of the strings DateTime A = DateTime.Parse(date1); DateTime B = DateTime.Parse(date2); //initialize count of lucky dates int luckyDates = 0; //use while loop to iterate while (A
Источник: https://stackoverflow.com/questions/781 ... stead-of-5
Мобильная версия