cappuccino #6424(2008/06/04 00:26 GMT) [ C# ] Rating0/0=0.00
Console.WriteLine(check(new[] { 825, 102, 811, 140, 812, 125, 263 })); False
Console.WriteLine(check(new[] { 824, 102, 811, 140, 810, 155, 263 })); True
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
using System; using System.Linq; class Program { static void Main() { Console.WriteLine(check(new[] { 825, 102, 811, 140, 812, 125, 263 })); Console.WriteLine(check(new[] { 824, 102, 811, 140, 810, 155, 263 })); } static bool check(int[] ls) { if (ls.Count() <= 1) { return true; } else if (ls.First() < ls.Skip(1).First()) { return ls.Skip(1).All(n => ls.First() < n) && check(ls.Skip(1).ToArray()); } else if (ls.First() > ls.Skip(1).First()) { return ls.Skip(1).All(n => ls.First() > n) && check(ls.Skip(1).ToArray()); } else { return false; } } }
Rating0/0=0.00-0+
[ reply ]
cappuccino
#6424()
[
C#
]
Rating0/0=0.00
Console.WriteLine(check(new[] { 825, 102, 811, 140, 812, 125, 263 })); False
Console.WriteLine(check(new[] { 824, 102, 811, 140, 810, 155, 263 })); True
Rating0/0=0.00-0+
[ reply ]