标签:c style class blog code java
1 //将一个字符串数组的元素的顺序进行反转。{"3","a","8","haha"} {"haha","8","a","3"}。第i个和第length-i-1个进行交换。 2 string[] strs = { "3", "a", "8", "haha" }; 3 for (int i = 0; i < strs.Length / 2; i++) 4 { 5 //i,len-1-i 6 //交换两个元素,想像一下交换i,j,交换两个杯子中的水 7 string temp = strs[i]; 8 strs[i] = strs[strs.Length - 1 - i]; 9 strs[strs.Length - 1 - i] = temp; 10 } 11 12 for (int i = 0; i < strs.Length; i++) 13 { 14 Console.Write(strs[i]+","); 15 }
2014年6月7日04:23:23,布布扣,bubuko.com
标签:c style class blog code java
原文地址:http://www.cnblogs.com/skyl/p/3773957.html