using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 答题2
{
class Program
{
public static void Main(string[] args)
{
int[] nums = { 1, 20, 35, 8, -20, 230, 38 };
int jiaohuan;
for (int i = 0; i < nums.Length; i++)
{
for (int j = 0; j < nums.Length - i - 1; j++)
{
if (nums[j] < nums[j + 1])
{
jiaohuan = nums[j];
nums[j] = nums[j + 1];
nums[j + 1] = jiaohuan;
}
}
}
for (int i = 0; i < nums.Length; i++)
{
if (nums[i] >= 0)
Console.Write("【{0}】 ", nums[i]);
}
Console.ReadKey();
}
}
} |
-
1.jpg
(51.7 KB, 下载次数: 48)
|