高难度,求算法谢谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
二维数组如下
ab
xy
12
cd
结果如下(排序可不同):
ax1cax1dax2cax2day1cay1day2cay2d
bx1cbx1dbx2cbx2dby1cby1dby2cby2d
先感谢大虾指导.谢谢 算法 c 排序
[解决办法]
搜 “笛卡尔乘积”
[解决办法]
public static void ShowResult()
{
string str = "X,P
[解决办法]
黑色,红色
[解决办法]
T,C";
string[] temp1 = str.Split('
[解决办法]
');
List<string> list = new List<string>();
foreach (string s in temp1)
{
if (list.Count == 0)
list.AddRange(s.Split(','));
else
list = JoinPart(list, s.Split(','));
}
foreach (string s in list)
Console.WriteLine(s);
}
public static List<string> JoinPart(List<string> part1, string[] part2)
{
List<string> result = new List<string>();
foreach (string str1 in part1)
{
foreach (string str2 in part2)
{
result.Add(str1 + " " + str2);
}
}
return result;
}