展开全部
clear
a=input('Input str:','s');
a
n=length(a)
abcnum=0;
spcnum=0;
numnum=0;
othnum=0;
for i=1:n
if ((a(i)>='a')&&(a(i)<='z'))...
||((a(i)>='A')&&(a(i)<='Z'))
abcnum=abcnum+1;
elseif ((a(i)>='0')&&(a(i)<='9'))
numnum=numnum+1;
elseif (a(i)==' ')
spcnum=spcnum+1;
else
othnum=othnum+1;
end
end
abcnum
numnum
spcnum
othnum
a=input('Input str:','s');
a
n=length(a)
abcnum=0;
spcnum=0;
numnum=0;
othnum=0;
for i=1:n
if ((a(i)>='a')&&(a(i)<='z'))...
||((a(i)>='A')&&(a(i)<='Z'))
abcnum=abcnum+1;
elseif ((a(i)>='0')&&(a(i)<='9'))
numnum=numnum+1;
elseif (a(i)==' ')
spcnum=spcnum+1;
else
othnum=othnum+1;
end
end
abcnum
numnum
spcnum
othnum
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询