用vb怎么编程第一行为123456,第二行为112345,第三行为111234

用vb怎么编程第一行为123456,第二行为112345,第三行为111234

就三行吗?还是?

通用的算法:
第一行的字符串为完成的。
从第二行开始,n-1个1字符,加上该字符串的左边(字符串长度-n+1)个

代码:
s=“123456”
L=len(s) /即字符串的长度
print s
for n=2 to L
temp="" /初始temp为空
for i=1 to n-1
temp=temp+"1"
next i /上i循环,就是前面1的个数。由行数确定,第二行为1个1,第三行为2个1,当然不包括1234中的1。
ss=temp+left(s,L-n+1)
print ss
next n

输出结果为
123456
112345
111234
111123
111112
111111
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-03-23
dim s as string
s = "2345"
for i = 1 to 3
for j = 1 to i
picture1.print j ;
next j
picture1.print left(s,6-i)
next i
第2个回答  2011-03-23
dim b as string
b="23456"
for i=1 to 3
for j=1 to i
b="1" & b
next j
b="23456"
next i
相似回答