源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

asp.net下实现输入数字的冒泡排序

  • 时间:2022-01-31 04:44 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:asp.net下实现输入数字的冒泡排序
[u]复制代码[/u] 代码如下:
protected void btnSort_Click(object sender, EventArgs e) { string array1 = txtSort.Text.Trim(); string[] array21=array1.Split(','); int dxiao = array21.Length; int[] array = new int[dxiao]; int temp=0; for (int i = 0; i < array.Length; i++) { array[i] = Convert.ToInt32(array21[i]); } for (int i = 0; i < array.Length - 1; i++) { for (int j = i + 1; j < array.Length; j++) { if (array[j] < array[i]) { temp = array[i]; array[i] = array[j]; array[j] = temp; } } } for (int i = 0; i < dxiao; i++) { lbsort.Text = lbsort.Text + " " + Convert.ToString(array[i]); } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部