冒泡排序
时间:2010-08-26 来源:shizhi57
public void sz()
{
int[] nums = { 1, 5, 8, 9, 3, 6, 7 };
for (int i = 0; i < nums.Length; i++)
{
for (int j = i+1; j < nums.Length; j++)
{
int temp = 0;
if (nums[i] < nums[j])
{
temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}
for (int m = 0; m < nums.Length; m++)
{
Response.Write(nums[m].ToString()+"<br>");
}
}
{
int[] nums = { 1, 5, 8, 9, 3, 6, 7 };
for (int i = 0; i < nums.Length; i++)
{
for (int j = i+1; j < nums.Length; j++)
{
int temp = 0;
if (nums[i] < nums[j])
{
temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}
for (int m = 0; m < nums.Length; m++)
{
Response.Write(nums[m].ToString()+"<br>");
}
}
相关阅读 更多 +