热心网友的回答:
其实这个很简单吧,就是查询每个空格之间的长度,把最长的那个显示出来而已。
热心网友的回答:
private sub ***mand1_click()
dim word() as string, longestword as string, longestwordlength as integer
word = split(left(text1.text, len(text1.text) - 1), " ")
longestwordlength = 0
for i = lbound(word) to ubound(word)
if len(word(i)) > longestwordlength then
longestword = word(i)
longestwordlength = len(word(i))
end if
next i
label1.caption = "最长的单词为「" + longestword + "」,其长度为" + cstr(longestwordlength) + "。"
end sub
热心网友的回答:
private sub ***mand1_click()
dim t as string, t1 as string, t2 as string * 1
dim i as integer, j as integer, l as integer, ascii as integer, m as integer, k as integer
t = inputbox("please input a sentence ,end of .")
l = len(t)
redim a(l) as string
redim n(l) as integer
j = 1
for i = 1 to l
t1 = mid(t, i, 1)
if t1 = "" then t1 = " "
ascii = asc(t1)
if (ascii > 65 and ascii < 90) or (ascii > 97 and ascii < 122) then
a(j) = a(j) + t1
n(j) = n(j) + 1
else
if n(j) > n(j - 1) then m = n(j): k = j
j = j + 1
end if
next
print "the longest word is:" & a(k) & ", long is: " & m
end sub
输入一行英文句子(单词之间有一个空格,最后用句号结束)找出其中最长的单词,输入该单词和它的长度。要
热心网友的回答:
其实这个很简单吧,就是查询每个空格之间的长度,把最长的那个显示出来而已。
用vb找出一个英文句子中最长的单词,并输出其长度
落叶l无情的回答:
tx=left(trim(text1),len(trim(text1))-1) '去开始和结尾的空格及结尾的标点符号
s=split(tx," ")
l=len(s(0))
for i=1 to ubound(s)
if len(s(i))>l then l=len(s(i))next
label3.caption=l
热心网友的回答:
private sub ***mand1_click()dim stra() as string, changdu as integer
stra = split(text1.text, " ")for i = lbound(stra()) to ubound(stra())
if changdu <= len(stra(i)) then changdu = len(stra(i))
next
msgbox "最长的字元的长度为:" & changduend sub
编写一个程式,输入一行英文句子,统计其中的单词个数.假设单词间仅使用空格(可能会有多个空格隔开)
热心网友的回答:
#include
#include
int main()
printf("the word number is %d \n",number);
return 0;}
利用c 的string类物件解决。可以先给物件赋一个空格字串,把从键盘接收的字元追加其后,以方便统一查询。举例如下 include stdafx.h if the vc 6.0,with this line.include include using namespace std int main i...
以下是在vb中的写法,修改于其他的版本,不区分大小写 dim tmp i lenstr sum tmp lcase text1.text lenstr len tmp for i 97 to 122 sum lenstr len replace tmp,chr i if sum 0 then pri...
格式 段落 中文版式 勾选允许西文在段落中间换行 格式 段落 中文版式 不选自动调整中文与西文的间距 很简单,帮助里面有介绍 开启word文件 工具 选项 拼写和语法 键入时检查拼写 确定 为什么在word中打英文或者是字母的时候,一行未写满却跳到下一行?格式 段落 中文板式 勾选 允许西文在单词中...