vfp程序设计 如何统计一句话中汉字和字母的个数
展开全部
CLOSE ALL
CLEAR ALL
CLEAR
ACCEPT "请输入一句话:" TO cMyStr
IF EMPTY(cMyStr)
?"没有输入字符!"
RETURN
ENDIF
cMyStr = ALLTRIM(cMyStr)
?"您输入的这句话中"
?"有 " + ALLTRIM(STR(LEN(cMyStr) - LENC(cMyStr))) + " 个汉字(含全角符号);"
nNumEngCnt = 0
nUppEngCnt = 0
nLowEngCnt = 0
nOthEngCnt = 0
FOR nLoop_01 = 1 TO LEN(cMyStr)
DO CASE
CASE BETWEEN(ASC(SUBSTR(cMyStr, nLoop_01, 1)), 48, 57)
nNumEngCnt = nNumEngCnt + 1
CASE BETWEEN(ASC(SUBSTR(cMyStr, nLoop_01, 1)), 65, 90)
nUppEngCnt = nUppEngCnt + 1
CASE BETWEEN(ASC(SUBSTR(cMyStr, nLoop_01, 1)), 97, 122)
nLowEngCnt = nLowEngCnt + 1
CASE ASC(SUBSTR(cMyStr, nLoop_01, 1)) > 128
nLoop_01 = nLoop_01 + 1
OTHERWISE
nOthEngCnt = nOthEngCnt + 1
ENDCASE
NEXT
?"有 " + ALLTRIM(STR(nNumEngCnt)) + " 个数字;"
?"有 " + ALLTRIM(STR(nUppEngCnt)) + " 个大写英文字母;"
?"有 " + ALLTRIM(STR(nLowEngCnt)) + " 个小写英文字母;"
?"有 " + ALLTRIM(STR(nOthEngCnt)) + " 个其它符号。"
RETURN
CLEAR ALL
CLEAR
ACCEPT "请输入一句话:" TO cMyStr
IF EMPTY(cMyStr)
?"没有输入字符!"
RETURN
ENDIF
cMyStr = ALLTRIM(cMyStr)
?"您输入的这句话中"
?"有 " + ALLTRIM(STR(LEN(cMyStr) - LENC(cMyStr))) + " 个汉字(含全角符号);"
nNumEngCnt = 0
nUppEngCnt = 0
nLowEngCnt = 0
nOthEngCnt = 0
FOR nLoop_01 = 1 TO LEN(cMyStr)
DO CASE
CASE BETWEEN(ASC(SUBSTR(cMyStr, nLoop_01, 1)), 48, 57)
nNumEngCnt = nNumEngCnt + 1
CASE BETWEEN(ASC(SUBSTR(cMyStr, nLoop_01, 1)), 65, 90)
nUppEngCnt = nUppEngCnt + 1
CASE BETWEEN(ASC(SUBSTR(cMyStr, nLoop_01, 1)), 97, 122)
nLowEngCnt = nLowEngCnt + 1
CASE ASC(SUBSTR(cMyStr, nLoop_01, 1)) > 128
nLoop_01 = nLoop_01 + 1
OTHERWISE
nOthEngCnt = nOthEngCnt + 1
ENDCASE
NEXT
?"有 " + ALLTRIM(STR(nNumEngCnt)) + " 个数字;"
?"有 " + ALLTRIM(STR(nUppEngCnt)) + " 个大写英文字母;"
?"有 " + ALLTRIM(STR(nLowEngCnt)) + " 个小写英文字母;"
?"有 " + ALLTRIM(STR(nOthEngCnt)) + " 个其它符号。"
RETURN
2009-12-21
展开全部
没有字数统计吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询