摘要: 有一个无限大的棋盘,棋盘上有一匹马,马移动的方式为日字型。即假设马当前的位置为(x,y),那么下一步可以移动到(x+1,y+2),(x+1,y-2),(x-1,y+2),(x-1,y-2),(x+2,y+1),(x+2,y-1),(x-2,y+1)或者(x-2,y-1)这8个位置。问马是否能从坐标(x,y)按照上述移动规则移动到坐标(x2,y2)。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication9{ class Pro... 阅读全文
posted @ 2014-01-28 16:12 Ligeance 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 8. 有一个包含n个元素的数组arr,计算最大的子段和(允许空段),即。9.有一个包含n个元素的首尾相连的环形数组arr,计算最大的子段和(允许空段)。样例:数组[1, 3, -2, 6, -1],最大子段和应该为9,对应的子段为[6, -1, 1, 3]。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication8{ class Program { static void Main(string[] ar... 阅读全文
posted @ 2014-01-28 15:14 Ligeance 阅读(579) 评论(0) 推荐(0) 编辑