Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Found many section of times intersect (Question version)
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Globalization; namespace Rextester { class TimeRange { public DateTime Start{get;set;} public DateTime? End{get;set;} public string Status{get;set;} } public class Program { public static void Main(string[] args) { Console.WriteLine("HoaND:_"); var provider = new CultureInfo("de-DE"); // Result store here var rs = new List<TimeRange>(); //Init template data var list = new List<TimeRange>{ new TimeRange{ Start = DateTime.ParseExact("08.05.2016", "d", provider), End = DateTime.ParseExact("20.05.2016", "d", provider), //End = null, //=> i can input END time is Null Status = "" }, new TimeRange{ Start = DateTime.ParseExact("17.05.2016", "d", provider), End = DateTime.ParseExact("25.05.2016", "d", provider), //End = null, //=> i can input END time is Null Status = "" }, new TimeRange{ Start = DateTime.ParseExact("27.05.2016", "d", provider), End = DateTime.ParseExact("28.05.2016", "d", provider), //End = null, //=> i can input END time is Null Status = "" } }; //Your code goes here //TODO: //Print results foreach(var item in rs){ Console.WriteLine(string.Format("{0} -> {1},Status={2}", item.Start.ToShortDateString(), item.End != null ? item.End.Value.ToShortDateString() : "NULL", item.Status )); } /* *Requirement* Test 1: => input (dd.mm.yyyy): t1 = 08.05.2016 -> 20.05.2016 t2 = 17.05.2016 -> 25.05.2016 t3 = 27.05.2016 -> 28.05.2016 => output: t1 = 08.05.2016 -> 17.05.2016, Status = normal t2 = 17.05.2016 -> 20.05.2016, Status = overlap t3 = 20.05.2016 -> 25.05.2016, Status = normal t4 = 27.05.2016 -> 28.05.2016, Status = normal Test 2: => input: t1 = 05.05.2016 -> 20.05.2016 t2 = 07.05.2016 -> 15.05.2016 t3 = 17.05.2016 -> 25.05.2016 => output: t1 = 05.05.2016 -> 07.05.2016, Status = normal t2 = 07.05.2016 -> 15.05.2016, Status = overlap t3 = 15.05.2016 -> 17.05.2016, Status = normal t4 = 17.05.2016 -> 20.05.2016, Status = overlap t5 = 20.05.2016 -> 25.05.2016, Status = normal Test3: => input: t1 = 05.05.2016 -> 07.05.2016 t2 = 15.05.2016 -> 20.05.2016 t3 = 22.05.2016 -> 25.05.2016 => output: t1 = 05.05.2016 -> 07.05.2016, Status = normal t2 = 15.05.2016 -> 20.05.2016, Status = normal t3 = 22.05.2016 -> 25.05.2016, Status = normal Test4: => Input: t1 = 08.05.2016 -> 20.05.2016 t2 = 17.05.2016 -> NULL => Output: t1 = 08.05.2016 -> 16.05.2016,Status=normal t2 = 17.05.2016 -> 20.05.2016,Status=overlap t3 = 20.05.2016 -> NULL,Status=normal Test5: => Input: t1 = 08.05.2016 -> NULL t2 = 17.05.2016 -> NULL => Output: t1 = 08.05.2016 -> 16.05.2016,Status=normal t2 = 17.05.2016 -> NULL,Status=overlap */ } } }
Show compiler warnings
[
+
]
Show input
edit mode
|
history
|
discussion