当前位置: 首页>>代码示例>>C#>>正文


C# Location.Select方法代码示例

本文整理汇总了C#中Location.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Location.Select方法的具体用法?C# Location.Select怎么用?C# Location.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Location的用法示例。


在下文中一共展示了Location.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static void Main(String[] args)
    {
        var n = Convert.ToInt32(Console.ReadLine());
        var a = new Location[n];

        for (var i = 0; i < n; ++i) {
            var line = Console.ReadLine().Split(new[] {' '});
            a[i] = new Location {
                Id = Convert.ToInt32(line[0]),
                   X = Convert.ToDouble(line[1]),
                   Y = Convert.ToDouble(line[2]),
            };
        }

        var m = Convert.ToInt32(Console.ReadLine());

        for (var i = 0; i < m; ++i) {
            var line = Console.ReadLine().Split(new[] {' '});

            var x = Convert.ToDouble(line[0]);
            var y = Convert.ToDouble(line[1]);

            double speed;
            switch (line[2]) {
                case "foot": speed = 5.0; break;
                case "bike": speed = 15.0; break;
                case "metro": speed = 20.0; break;
                default: throw new Exception("unknown transport");
            }

            var minutes = Convert.ToDouble(line[3]);

            var result = a
                .Select(p => new { p.Id, Distance = GetDistance(x, y, p.X, p.Y) })
                .Where(p => (p.Distance / speed) * 60.0 <= minutes)
                .OrderBy(p => p.Distance)
                .ThenBy(p => p.Id);

            Console.WriteLine(string.Join(" ", result.Select(p => p.Id.ToString())));
        }
    }
开发者ID:aleksandrpak,项目名称:solutions,代码行数:41,代码来源:solution.cs

示例2: GetScores

 private Dictionary<Location, int> GetScores(Location[] canPutLocations, Dictionary<Location, int> cubeLengths, Dictionary<Location, int> heightMap)
 {
     return canPutLocations
         .Select(location => new { location, score = GetScore(location, cubeLengths, heightMap) })
         .ToDictionary(x => x.location, x => x.score);
 }
开发者ID:MAX-eipi,项目名称:NOBOTTOWER,代码行数:6,代码来源:CubeManager.cs

示例3: Convert_Locations_To_Building

	public static Building[] Convert_Locations_To_Building(Location[] its_locations)
	{
		return its_locations.Select(repLocation => repLocation.TheSelf).ToArray();
	}
开发者ID:DarkXenoShark,项目名称:AI-ICA2-RTS,代码行数:4,代码来源:AgentMaster.cs


注:本文中的Location.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。