DATAS SEGMENT
w dw 0
keybuf db 255
db 0
db 255 dup(0) ;定義鍵盤輸入需要的緩沖區(qū)
DATAS ENDS
STACKS SEGMENT
db 200 dup(?)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
mov dx,offset keybuf ;用0a號(hào)功能,輸入一個(gè)字符串
mov ah,0ah ;用回車結(jié)束
int 21h
mov dl,0ah ;再進(jìn)行換行,以便在下一行顯示轉(zhuǎn)換后的字符串
mov ah,2
int 21h
; Push ax
; Push dx
; mov dl,cl
; mov ah,02
; int 21h
; pop dx
; pop ax
mov bx,offset keybuf+1 ;取出字符串的字符個(gè)數(shù),作為循環(huán)的次數(shù)
mov cl,[bx]
mov ch,0
mov ax,0
again:
inc bx
mov ax,[w]
Push bx
mov bx,16
mul bx
pop bx ;是小寫字母,則轉(zhuǎn)換為大寫字母
mov [w],ax
mov dl,[bx] ;取出一個(gè)字符,
cmp dl,'9'
jbe lab1
cmp dl,'F'
jbe lab2
sub dl,32
lab2: sub dl ,07h
lab1: sub dl,30h
add [w],dx
loop again
mov ax,[w]
mov bx,-1
Push bx
mov bx,10
lab3 :mov dx,0
div bx
Push dx
cmp ax,0
jnz lab3
lab5: pop dx
cmp dx,-1
jz lab4
add dl,30h
mov ah,02
int 21h
jmp lab5 ;循環(huán),處理完整個(gè)字符串
lab4: MOV AH,4CH
INT 21H
CODES ENDS
END START
標(biāo)簽:
匯編
上傳時(shí)間:
2015-04-02
上傳用戶:wcc0310
#include <stdlib.h>
#include<stdio.h>
#include <malloc.h>
#define stack_init_size 100
#define stackincrement 10
typedef struct sqstack
{
int *base;
int *top;
int stacksize;
} sqstack;
int StackInit(sqstack *s)
{
s->base=(int *)malloc(stack_init_size *sizeof(int));
if(!s->base)
return 0;
s->top=s->base;
s->stacksize=stack_init_size;
return 1;
}
int Push(sqstack *s,int e)
{
if(s->top-s->base>=s->stacksize)
{
s->base=(int *)realloc(s->base,(s->stacksize+stackincrement)*sizeof(int)); if(!s->base)
return 0;
s->top=s->base+s->stacksize;
s->stacksize+=stackincrement;
}
*(s->top++)=e;
return e;
}
int Pop(sqstack *s,int e)
{
if(s->top==s->base)
return 0;
e=*--s->top;
return e;
}
int stackempty(sqstack *s)
{
if(s->top==s->base)
{
return 1;
}
else
{
return 0;
}
}
int conversion(sqstack *s)
{
int n,e=0,flag=0;
printf("輸入要轉(zhuǎn)化的十進(jìn)制數(shù):\n");
scanf("%d",&n);
printf("要轉(zhuǎn)化為多少進(jìn)制:\n"); scanf("%d",&flag);
printf("將十進(jìn)制數(shù)%d 轉(zhuǎn)化為%d 進(jìn)制是:\n",n,flag);
while(n)
{
Push(s,n%flag);
n=n/flag;
}
while(!stackempty(s))
{
e=Pop(s,e);
switch(e)
{
case 10: printf("A");
break;
case 11: printf("B");
break;
case 12: printf("C"); break;
case 13: printf("D"); break;
case 14: printf("E"); break;
case 15: printf("F"); break;
default: printf("%d",e); }
}
printf("\n");
return 0;
}
int main()
{
sqstack s;
StackInit(&s);
conversion(&s);
return 0;
}
標(biāo)簽:
整數(shù)
棧
基本操作
十進(jìn)制
轉(zhuǎn)化
進(jìn)制
上傳時(shí)間:
2016-12-08
上傳用戶:愛你198
At present, there is a strong worldwide Push toward bringing fiber closer to indi-
vidual homes and businesses. Fiber-to-the-Home/Business (FTTH/B) or close to it
networks are poised to become the next major success story for optical fiber com-
munications. In fact, FTTH connections are currently experiencing double-digit or
even higher growth rates, e.g., in the United States the annual growth rate was 112%
between September 2006 and September 2007, and their presence can add value of
U.S. $4,000–15,000 to the selling price of a home.
標(biāo)簽:
Technologies
Broadband
Networks
Access
上傳時(shí)間:
2020-05-26
上傳用戶:shancjb