在PB中对数组采用冒泡排序法为什么一直无法成功【附有代码】

ToddSong 2008-10-26 12:04:51
for m=1 to l - 1
num1=integer(out_number[m]);
for n=m+1 to l - m - 1
num2=integer(out_number[n]);
if(num1<num2) then
tmp[1]=out_number[m];out_number[m]=out_number[n];out_number[n]=tmp[1];
tmp[2]=class[m];class[m]=class[n];class[n]=tmp[2];
tmp[3]=code[m];code[m]=code[n];code[n]=tmp[3];
tmp[4]=namename[m];namename[m]=namename[n];namename[n]=tmp[4];
end if
next
next
...全文
255 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
WorldMobile 2008-11-05
  • 打赏
  • 举报
回复
楼主的结贴率也太低了吧?
LamarChen 2008-10-26
  • 打赏
  • 举报
回复
看出来了
应该是 for n=m+1 to l - 1
你写成了 for n=m+1 to l - m - 1

for m=1 to l - 1
num1=integer(out_number[m]);
for n=m+1 to l - 1 ////
num2=integer(out_number[n]);
if(num1 < num2) then
tmp[1]=out_number[m];out_number[m]=out_number[n];out_number[n]=tmp[1];
tmp[2]=class[m];class[m]=class[n];class[n]=tmp[2];
tmp[3]=code[m];code[m]=code[n];code[n]=tmp[3];
tmp[4]=namename[m];namename[m]=namename[n];namename[n]=tmp[4];
end if
next
next

LamarChen 2008-10-26
  • 打赏
  • 举报
回复
建议把代码编排一下 再试试!
因为PB有时候也很糊涂的!!
LamarChen 2008-10-26
  • 打赏
  • 举报
回复

for m=1 to l - 1
num1=integer(out_number[m]);
for n=m+1 to l - m - 1
num2=integer(out_number[n]);
if(num1 < num2) then
tmp[1]=out_number[m];out_number[m]=out_number[n];out_number[n]=tmp[1];
tmp[2]=class[m];class[m]=class[n];class[n]=tmp[2];
tmp[3]=code[m];code[m]=code[n];code[n]=tmp[3];
tmp[4]=namename[m];namename[m]=namename[n];namename[n]=tmp[4];
end if
next
next
lllyyymmm 2008-10-26
  • 打赏
  • 举报
回复
你上面的程序没有错,至于为什么不行,可能要调试一下结果,你可以试几个断点

743

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 脚本语言
社区管理员
  • 脚本语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧