我需要数单词,哪里有比数字更多的大字母。
inr c
如果大字母在单词中并且dcr c
有数字,我会使用。在单词的末尾我尝试 c>0,如果它是真的,我会这样做inr d
。d
是大字母多于数字的单词数。问题是,c>0 总是正确的。(我认为,因为它计算所有单词)。
cpi 'A' ;find if it is letter
jnc mozno_pismeno
cpi '9'+1 :find if it is number
jc mozno_cislo
mozno_pismeno: ;maybe it is letter
cpi 'Z'+1 ;second chceck if it is letter
jc je_to_pismeno
jmp getchar_main
je_to_pismeno: ;it is letter so inr c
inr c
jmp getchar_main
mozno_cislo: ;maybe it is number
cpi '0' ;second check if it is number
jnc je_to_cislo
jmp getchar_main
je_to_cislo: ;it is number so dcr c
dcr c
jmp getchar_main
koniec_slova: ;it is end of the word
mov a,c
cpi 1 ;if c>0 that mean that there was more letters
jnc ma_viac_pismen
mvi c,0 ;prepare c for next one character
jmp getchar_main
ma_viac_pismen: ;c>0 so inr d
inr d
mvi c,0 ;prepare c for next one character
jmp getchar_main