没有合适的资源?快使用搜索试试~ 我知道了~
首页分别计算字符串中字母、数字及其他字符的数目
分别计算字符串中字母、数字及其他字符的数目
需积分: 44 990 浏览量
更新于2023-05-30
评论
收藏 30KB DOC 举报
程序接收用户输入的一行字符(字符个数不超过80个,字符串以回车符结束),并按字母、数字及其它字符分类统计,然后将结果显示出来。要求有信息提示用户按照要求输入字符,三类字符的个数分别在三行显示,并指明是哪类字符。
资源详情
资源评论
资源推荐

;Program: 分别计算字符串中字母、数字及其他字符的数目
;Author:
;Date: 9/2009
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h ; header file for input/output
cr EQU 0dh ; carriage return character
Lf EQU 0ah ; line feed
.STACK 4096 ; reserve 4096-byte stack
.DATA ; reserve storage for data
prompt1 byte cr,lf,"Enter a string:",0
string byte 80 dup(?)
letternum dword ?
digitnum dword ?
othernum dword ?
letter byte cr,lf,"The number of letters is :",0
digit byte cr,lf,"The number of digit is:",0
otherchar byte cr,lf,"The nunber of non-letter and non-digit character is :",0
num byte 11 dup(?)
byte cr,lf,0
.CODE ; start of main program code
_start:
mov letternum,0 ;字母数目=0
mov digitnum,0 ;数字数目=0
mov othernum,0 ;非数字字母数目=0
output prompt1
input string,80 ;输入字符串
lea esi,string ;取字符串首地址
dec esi ;首地址递减
whilecount: inc esi ;增加地址一位
mov al,[esi] ;将 esi 的地址中的字符复制到 al
cmp al,0 ;将该字符与停止符比较
je endwhile ;若相等,跳到 endwhile
jmp body ;否则,跳到 body

















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0