怎么写程序实现
N行N列二维表,每行取一个值,每列只能取一次,然后求和,最小和的取法。
比如
5 6 7
1 100 100
100 2 100
这个应该取7,1,2
怎么写程序实现?
[解决办法]
循环依次读取每行,得到该行最小列值,累加。
[解决办法]
List<List<int>> list = new List<List<int>>(){ new List<int>() { 5, 6, 7 }, new List<int>() { 1, 100, 100 }, new List<int>() { 100, 2, 100 }};int result = list.Select(x => x.Min()).Sum();