字符串冒泡排序 [英] String Bubble Sort

查看:85
本文介绍了字符串冒泡排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


任何人都可以帮助使用ASP对字符串进行冒泡排序吗?我有一个文本

文件的文件ID喜欢排序和计数。


提前感谢您的帮助。


Gram。

解决方案

Gram写道:

你好,

任何人都可以帮忙使用ASP对字符串进行冒泡排序?我有一个文字文件,其中包含类似于排序和计数的文字。

提前感谢您的帮助。

Gram。



这是一个简单的例子:

dim ar,i,j,vTemp

ar = array(狗,猫,鸟,猴子)

response.write"排序前:< BR>"

for i = 0 to ubound(ar)

回复.write ar(i)& < BR>"

next

for i = 0 to ubound(ar)-1

for j = i + 1到ubound(ar)

如果ar(j)< = ar(i)那么

vTemp = ar(j)

ar( j)= ar(i)

ar(i)= vTemp

结束如果

next

next

response.write"排序后:< BR>"

for i = 0 to ubound(ar)

response.write ar (i)& < BR>"

next


要对数字进行排序,请更改if ar(j)< = ar(i)then toif cdbl(ar(j))< =

cdbl(ar(i))then,或cint,clng等,具体取决于数字的类型

你正在整理。

HTH,

Bob Barrows


感谢Bob,


你忘记了字符串周围的引号但是没有工作

没有它们

ar = array(" ; dog,cat,bird,monkey)


再次感谢Bob


Gram。


" Gram" < GR ****** @ hotmail.com>在消息中写道

新闻:MI ******************* @ news.indigo.ie ...

您好,

任何人都可以帮助使用ASP对字符串进行冒泡排序吗?我有一个
文本文件,其中的文字ID类似于排序和计数。

提前感谢您的帮助。

Gram。


冒泡排序很垃圾而且速度很慢。


这个数字可能不错,但有些研究会发现很多

更好的选择。

例如...
http://www.cs.ubc.ca/spider/harrison...ting-demo.html


即使你不使用任何这些,它们真的很有趣。

Tim

" Gram" < GR ****** @ hotmail.com>在消息中写道

新闻:MI ******************* @ news.indigo.ie ...

您好,

任何人都可以帮助使用ASP对字符串进行冒泡排序吗?我有一个
文本文件,其中的文字ID类似于排序和计数。

提前感谢您的帮助。

Gram。


Hello,

Can anyone help out with a bubble sort for strings using ASP? I have a text
file of words id like to sort and count.

Thanks in advance for any help.

Gram.

解决方案

Gram wrote:

Hello,

Can anyone help out with a bubble sort for strings using ASP? I have
a text file of words id like to sort and count.

Thanks in advance for any help.

Gram.



Here''s a quick example:
dim ar, i , j, vTemp
ar=array(dog,cat,bird,monkey)
response.write "Before Sort:<BR>"
for i = 0 to ubound(ar)
response.write ar(i) & "<BR>"
next
for i=0 to ubound(ar)-1
for j = i+1 to ubound(ar)
if ar(j) <= ar(i) then
vTemp = ar(j)
ar(j) = ar(i)
ar(i) = vTemp
end if
next
next
response.write "After Sort:<BR>"
for i = 0 to ubound(ar)
response.write ar(i) & "<BR>"
next

To sort numbers, change "if ar(j) <= ar(i) then" to "if cdbl(ar(j)) <=
cdbl(ar(i)) then", or cint, clng, etc., depending on what type of numbers
you are sorting.
HTH,
Bob Barrows


Thanks for that Bob,

You forgot the quotes around the words for the strings though, doesn''t work
without them
ar=array("dog","cat","bird","monkey")

Thanks again Bob

Gram.

"Gram" <gr******@hotmail.com> wrote in message
news:MI*******************@news.indigo.ie...

Hello,

Can anyone help out with a bubble sort for strings using ASP? I have a text file of words id like to sort and count.

Thanks in advance for any help.

Gram.



bubble sort is rubbish and slow.

with small numbers this might be fine, but a bit of research will find much
better alternatives.
for example...
http://www.cs.ubc.ca/spider/harrison...ting-demo.html

even if you dont use any of these, they are really interesting.
Tim
"Gram" <gr******@hotmail.com> wrote in message
news:MI*******************@news.indigo.ie...

Hello,

Can anyone help out with a bubble sort for strings using ASP? I have a text file of words id like to sort and count.

Thanks in advance for any help.

Gram.



这篇关于字符串冒泡排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆