匿名 #5572(2008/01/30 15:28 GMT) [ C# ] Rating0/0=0.00
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
using System; using System.Collections; using System.Collections.Generic; class Program { static void Main() { string input = @"5 8 5 6 4 4 3 7 10 0 10 10 10 5 2 7 9 7 8 10 10 2 1 2 8 1 6 7 6 0 0 9"; List<Location> seiza = new List<Location>(); Location seizaDefault = new Location() { X = -1, Y = -1 }; List<Location> yozora = new List<Location>(); Location yozoreDefault = new Location() { X = -1, Y = -1 }; List<Location> tmpYozora; IEnumerator input_ = input.Split(new char[] { '\n' }).GetEnumerator(); input_.MoveNext(); input_.MoveNext(); while(((string)input_.Current).Trim().Split(new char[] { ' ' }).Length != 1) { int x, y; string[] row = ((string)input_.Current).Trim().Split(new char[] { ' ' }); x = int.Parse(row[0].Trim()); y = int.Parse(row[1].Trim()); if(seizaDefault.Equals(new Location() { X = -1, Y = -1 })) { seizaDefault = new Location() { X = x, Y = y }; seiza.Add(new Location() { X = 0, Y = 0 }); } else { seiza.Add(new Location() { X = x - seizaDefault.X, Y = y - seizaDefault.Y }); } input_.MoveNext(); } input_.MoveNext(); do { int x, y; string[] row = ((string)input_.Current).Trim().Split(new char[] { ' ' }); x = int.Parse(row[0].Trim()); y = int.Parse(row[1].Trim()); yozora.Add(new Location() { X = x, Y = y }); } while(input_.MoveNext()); foreach(Location defaultStar in yozora) { Location Default = defaultStar; tmpYozora = new List<Location>(); foreach(Location star in yozora) { tmpYozora.Add(new Location() { X = star.X - Default.X, Y = star.Y - Default.Y }); } if(Hikaku(seiza, tmpYozora)) { Console.WriteLine((Default.X - seizaDefault.X) + " " + (Default.Y - seizaDefault.Y)); break; } } Console.ReadLine(); } static bool Hikaku(List<Location> seiza, List<Location> yozora) { foreach(Location star in seiza) { if(!yozora.Contains(star)) return false; } return true; } } struct Location { public int X; public int Y; }
Rating0/0=0.00-0+
[ reply ]
匿名
#5572()
[
C#
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]