繁體中文
当前位置:首页 > 信息世界 > 程序源码 > 详细内容
『vb』冒泡法对n个数从小到大排序
发布时间:2009/7/5  阅读次数:2762  字体大小: 【】 【】【
private sub form_click()
dim nums()
dim i as integer,j as integer,n as integer,t as integer
n=val(inputbox("请输入参加排序的数:"))
redim nums(1 to n)
for i=1 to n
nums(i)=val(inputbox("请输入第"&str(i)&"个参加排序的数"))
next i
for i=1 to n-1
for j=1 to n-i
if nums(j)>nums(j+1) then
t=nums(j)
nums(j)=nums(j+1)
nums(j+1)=t
end if
next j
next i
for i=1 to n
print nums(i);
next i
end sub

我要评论
  • 匿名发表
  • [添加到收藏夹]
  • 发表评论:(匿名发表无需登录,已登录用户可直接发表。) 登录状态:未登录
最新评论
所有评论[0]
    暂无已审核评论!
 
 版权声明     关于本站      在线留言       登陆管理      个人博客   
 『辰桦网络』. All Rights Reserved
Station construction time: on April 4, 2006