码迷,mamicode.com
首页 > 其他好文 > 详细

2014年6月7日04:23:23

时间:2014-06-07 16:53:41      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

bubuko.com,布布扣
 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             }
bubuko.com,布布扣

 

2014年6月7日04:23:23,布布扣,bubuko.com

2014年6月7日04:23:23

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/skyl/p/3773957.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!