Функция, возвращающая 8 вместо 5C#

Место общения программистов 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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»