1个回答
展开全部
public class Test
{
public static void main(String args[])
{
int[] arr = {4, 1, 2, 6, 3, 8, 9, 10, 7, 5};
for (int i = 0; i < 10; i++)
System.out.print(arr[i] + " ");
System.out.println();
for (int i = 0; i < 10 - 1; i++)
for (int j = 0; j < 10 - 1 - i; j++)
{
if (arr[j] > arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
for (int i = 0; i < 10; i++)
System.out.print(arr[i] + " ");
}
}
{
public static void main(String args[])
{
int[] arr = {4, 1, 2, 6, 3, 8, 9, 10, 7, 5};
for (int i = 0; i < 10; i++)
System.out.print(arr[i] + " ");
System.out.println();
for (int i = 0; i < 10 - 1; i++)
for (int j = 0; j < 10 - 1 - i; j++)
{
if (arr[j] > arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
for (int i = 0; i < 10; i++)
System.out.print(arr[i] + " ");
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询