编写比较两字符串大小的程序,并判定一个子串在一个字符串中出现的次数,如果该子串不出现反加值0
1个回答
展开全部
下面是vb的例子
dim str1 as string,str2 as string,str3 as string,n1 as long,i as long,ii as long
str1="he word error , has different meanings in different domains. The concrete meaning of the Latin word error means ... Human factors engineering is often applied to designs in an attempt to minimize this type of error by making ..."
'///////////////////假设从这句话中读取“error”的个数
do
doevents
str2=mid(str1,1,i)'//////////////读取一个字符
if(str2="e") then
ii=i+1
str2=mid(str1,1,ii)
if(str2="r") then
ii=ii+1
str2=mid(str1,1,ii)
if(str2="r") then
ii=ii+1
str2=mid(str1,1,ii)
if(str2="o") then
ii=ii+1
str2=mid(str1,1,ii)
if(str2="r") then
n1=n1+1
end if
end if
end if
end if
end if
i=i+1
loop until i=len(str1)'///////////////达到长度后停止,n1就是个数
dim str1 as string,str2 as string,str3 as string,n1 as long,i as long,ii as long
str1="he word error , has different meanings in different domains. The concrete meaning of the Latin word error means ... Human factors engineering is often applied to designs in an attempt to minimize this type of error by making ..."
'///////////////////假设从这句话中读取“error”的个数
do
doevents
str2=mid(str1,1,i)'//////////////读取一个字符
if(str2="e") then
ii=i+1
str2=mid(str1,1,ii)
if(str2="r") then
ii=ii+1
str2=mid(str1,1,ii)
if(str2="r") then
ii=ii+1
str2=mid(str1,1,ii)
if(str2="o") then
ii=ii+1
str2=mid(str1,1,ii)
if(str2="r") then
n1=n1+1
end if
end if
end if
end if
end if
i=i+1
loop until i=len(str1)'///////////////达到长度后停止,n1就是个数
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询