有没有能实现这种的: 1 2 3 4 8 7 6 5 9 10 11 12 ..... 有没有能实现这种排序的: 1 2 3 4 8 7 6 5 9 10 11 12 ..... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 int count = 1; for (int i = 0; i < a.Length; i += 4) { if (count % 2 == 0) { swap(ref a[i], ref a[i + 3]); swap(ref a[i + 1], ref a[i + 2]); } count++; } 前面加上一句Array.Sort(a);a是你的数组 swap是什么?没用过这个方法 螺旋矩阵???用for循环嵌套吧 本帖最后由 caozhy 于 2012-05-31 19:04:10 编辑 a、b互换1 2 3 4 --> 4 2 3 1 --> 4 3 2 1两次互换 asp.net如何限制TextBox里整数值范围 动态实例,新手问题 DataGridView中DataGridViewImageCell图片列问题!!! 【关于 WinForm 下 DataGridView 绑定List<T> 的问题】 Unicode问题 求助:数据库.bak文件追加数据 求windows xp sp2版操作系统的下载连接 连接数据库,程序挂死的问题 如何得到当前程序的路径——如vb里的app.path c#中,如何组织主从表中的从表的输入?on line waiting! 关于“Silverlight”下“DataGrid控件”的疑问 求高手在线等
for (int i = 0; i < a.Length; i += 4)
{
if (count % 2 == 0)
{
swap(ref a[i], ref a[i + 3]);
swap(ref a[i + 1], ref a[i + 2]);
}
count++;
}
Array.Sort(a);a是你的数组
swap是什么?没用过这个方法
a、b互换
1 2 3 4 --> 4 2 3 1 --> 4 3 2 1
两次互换