我现在有一个一个字符串分别是
1,2,3,4,5,6
现在要把每一个数字分别组合!!不是他自已本身!!如
1和2组合
1和3组合
1和4组合
1和5组合
1和6组合
2和3组合
2和4组合
2和5组合
2和6组合
3和4组合
3和5组合
3和6组合4和5组合
4和6组合5和6组合
怎样把这些组合的数字列出呢
1,2,3,4,5,6
现在要把每一个数字分别组合!!不是他自已本身!!如
1和2组合
1和3组合
1和4组合
1和5组合
1和6组合
2和3组合
2和4组合
2和5组合
2和6组合
3和4组合
3和5组合
3和6组合4和5组合
4和6组合5和6组合
怎样把这些组合的数字列出呢
string[] strs = str.Split(',');
int len = strs.Length;
for(int i = 0; i < len; ++i)
for(int j = i + 1; j < len; ++j)
Console.WriteLine(strs[i] + strs[j]);
string[] strs = str.Split(',');
int len = strs.Length;
for(int i = 0; i < len-1; ++i)
for(int j = i + 1; j < len; ++j)
Console.WriteLine(strs[i] + strs[j]);
string[] strs = str.Split(',');
int len = strs.Length;
for(int i = 0; i < len-1; ++i)
{
for(int j = i + 1; j < len; ++j)
}
if(strs[i]!=strs[j])
{
Console.WriteLine(strs[i] + strs[j]);
}
}
}
string[] strs = str.Split(',');
int len = strs.Length;
for(int i = 0; i < len-1; ++i)
for(int j = i + 1; j < len; ++j)
Console.WriteLine(String.Format("{0}和{1}组合",strs[i] ,strs[j]));