主题:这个题可以这样吗?
从键盘上输入若干个单词,计算机自动排列顺序(A-Z)打印出来?
第一种思路:是这样子的。:
input n '表示有n个单词
dim a$(n)
‘赋值
for i=1 to n
input a$(i)
next i
’选择排序法
for i=1 to n-1
k=i
for j=i+1 to n
if a$(k)>a$(j) then k=j
next j
if k<>i then swap a$(i),a(k)
next i
'输出
for i=1 to n
? a$(i);
next i
end
如:键盘输入个数为:n=3
串为:school
abc
xyzp
结果为:abcschoolxyzp (只比较这整个单词的大小)
第二种思路是:
按题目的意思。结果是不是应该为:abcchloopsxyz (拆分每个字母并从小到大排序)。那又应该什么编,
第一种思路:是这样子的。:
input n '表示有n个单词
dim a$(n)
‘赋值
for i=1 to n
input a$(i)
next i
’选择排序法
for i=1 to n-1
k=i
for j=i+1 to n
if a$(k)>a$(j) then k=j
next j
if k<>i then swap a$(i),a(k)
next i
'输出
for i=1 to n
? a$(i);
next i
end
如:键盘输入个数为:n=3
串为:school
abc
xyzp
结果为:abcschoolxyzp (只比较这整个单词的大小)
第二种思路是:
按题目的意思。结果是不是应该为:abcchloopsxyz (拆分每个字母并从小到大排序)。那又应该什么编,