主题:菜鸟中的菜鸟求教啊
F夕T阳
[专家分:0] 发布于 2006-06-22 21:52:00
各位大虾在看完以下内容之后,千万不要笑我.
是这样的本人今天心血来潮,跑到书店买了本谭浩强写的QB教材在家研究
到现在看到了选择结构程序设计
看完之后不知咋的
就是不会做后面的题[em8]
哪位大虾能够指点一下啊
题目是:键入任意个大小写英文字母,分别统计并输出键入的大写和小写英文字母的个数
再次申明:别笑我
回复列表 (共8个回复)
沙发
老大徒伤悲 [专家分:29120] 发布于 2006-06-23 09:07:00
我有一个笨办法:
dim x(52)
input a$
upb=asc("A")
upe=asc("Z")
lob=asc("a")
loe=asc("z")
for i=1 to len(a$)
n=asc(mid(a$,i,1))
if n>=upb and n<=upe then
n=n-upb+1
x(n)=x(n)+1
endif
if n>=lob and n<=loe then
n=n-lob+27
x(n)=x(n)+1
endif
next i
for i=1 to 52
if i<27 then
? chr$(i+upb-1);
else
? chr$(i+lob-27);
endif
? x(i)
next i
end
哈哈哈哈,里面有些函数和语句很久不用了,有错的地方,大家海涵阿。
原理是笨了点,但功能是应该可以实现的。
板凳
moz [专家分:37620] 发布于 2006-06-23 10:31:00
input a$
for i=1 to len(a$)
select case asc(mid$(a$,i,1))
case 65 to 90
Da=Da+1
case 97 to 120
Xiao=Xiao+1
end select
next
print "Da";Da,"Xiao";Xiao
3 楼
F夕T阳 [专家分:0] 发布于 2006-06-23 13:07:00
多谢各位大虾
不过呢小弟刚刚入门还没学循环呢
那个1楼的老大,小弟实在是看不懂你写的东西
不好意思拉,浪费了你的时间
2楼的大哥我还有件事请教
那个 mid$函数要怎么用啊
4 楼
moz [专家分:37620] 发布于 2006-06-23 13:58:00
MID$(stringexpression$,start%[,length%])
■ stringexpression$ The string from which the substring is to be
extracted. This can be any string expression.
■ start% The character position in stringexpression$
where the substring starts.
■ length% The number of characters to extract. This can
be omitted if you want all the characters to the
right of start%.
作为函数使用时,获得字符串 stringexpression$ 从位置 start% 开始的长度为 length% 的字符子串
5 楼
F夕T阳 [专家分:0] 发布于 2006-06-23 14:43:00
英语呢就看不太懂拉
这个汉语到是懂拉
那个
就多谢这位大哥拉
6 楼
JRX [专家分:180] 发布于 2006-07-01 13:42:00
键入任意个大小写英文字母,分别统计并输出键入的大写和小写英文字母的个数
INPUT "N=";N
S=0:T=0
FOR I=1 TO N
INPUT X$
IF X$>="A" AND X$<="B" THEN S=S+1 ELSE T=T+1
NEXT I
? "大写";S
? "小写";T
END
7 楼
少年雨生 [专家分:0] 发布于 2006-07-04 09:02:00
嘎.偶也是新手..
刚刚接触这个东东呵
听说QBASIC 学了后其它就好学了.
8 楼
593170024 [专家分:500] 发布于 2009-11-17 16:37:00
我好想笑哦
input a$
l= len (a$)
for i = 1 to l
m$ = mid$(a$ , i, 1)
if m$> = "A" and m$ < = "Z" then a=a+1
if m$> = "a" and m$ < = "z" then b=b+1
next i
? a,b
我来回复