国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

數(shù)組交換位置

2023-01-28 12:24 作者:此城過客  | 我要投稿

static string[]Jiaohuanweizhi(string[] names)//自定義函數(shù)

{

? ? ? ? for (int i = 0; i < names.Length / 2; i++)

? ? ? ? {

? ? ? ? ? ? ? ?string temp = names[i];

? ? ? ? ? ? ? ?names[i] = names[names.Length - 1 - i];

? ? ? ? ? ? ? ?names[names.Length - 1 - i] = temp;

? ? ? ? ?}

? ? ? ? return names;

}

static void Main(string[] args)

{

? ? ? ? string[] n= {"沖鋒槍", "步槍", "手槍", "機槍", "霰彈槍"};

? ? ? ? string[] m=Jiaohuanweizhi(n);

? ? ? ? foreach (string temp in m)

? ? ? ? {

? ? ? ? ? ? ? ? Console.WriteLine(temp);

? ? ? ? }

}

==========================================================

上面這是有返回值的。下面是無返回的。這種無返回的情況,只適用于數(shù)組。

static void?Jiaohuanweizhi(string[] names)//自定義函數(shù)

{

? ? ? ??for?(int i = 0; i < names.Length / 2; i++)

? ? ? ??{

? ? ? ? ? ? ? ?string?temp = names[i];

? ? ? ? ? ? ? ?names[i] = names[names.Length - 1 - i];

? ? ? ? ? ? ? ?names[names.Length - 1 - i] = temp;

? ? ? ? ?}

? ? ? ??return?names;

}

static void?Main(string[] args)

{

? ? ? ??string[] n= {"沖鋒槍", "步槍", "手槍", "機槍", "霰彈槍"};

? ? ? ??Jiaohuanweizhi(n);

? ? ? ??foreach?(string?temp?in?n)

? ? ? ??{

? ? ? ? ? ? ? ??Console.WriteLine(temp);

? ? ? ??}

}





數(shù)組交換位置的評論 (共 條)

分享到微博請遵守國家法律
宾阳县| 屏东市| 花垣县| 高清| 丹东市| 济宁市| 剑河县| 五大连池市| 澳门| 武威市| 历史| 宝清县| 漯河市| 保康县| 年辖:市辖区| 华安县| 错那县| 松溪县| 陇南市| 若羌县| 介休市| 宜州市| 时尚| 芜湖县| 康马县| 朝阳县| 眉山市| 望都县| 新泰市| 平武县| 沙河市| 信丰县| 遵义市| 滦平县| 禹城市| 敦煌市| 什邡市| 建阳市| 陈巴尔虎旗| 彭水| 鸡泽县|