模拟进度条(图形版)
程序代码:
#include <stdio.h> void redos(); void pause(unsigned int time); void screen_mode(unsigned char mode); void point(unsigned int x, unsigned int y, unsigned char colorID, unsigned char color ); void shape(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned char colorID, unsigned char color ); int main(void) { int x,y; screen_mode(0x12); printf("\n\n"); for(x=0; x<=500; x+=30) { shape(0,10,x,30,0,1); printf("%d\%\b\b\b",x/5); pause(1); } printf("100\%\b\b\b"); redos(); return 0; } void redos() { asm mov ah,7h; asm int 21h; asm mov ah,4ch; asm int 21h; } void pause(unsigned int time) { asm mov ah,0h; asm int 1ah; asm add dx,time; asm mov bx,dx; label: asm int 1ah; asm cmp bx,dx; asm jne label; } void screen_mode(unsigned char mode) { asm mov ah,0h; asm mov al,mode; asm int 10h; } void point(unsigned int x, unsigned int y, unsigned char colorID, unsigned char color ) { asm mov ah,0bh; asm mov bh,0x(colorID); asm mov bl,0x(color); asm int 10h; asm mov ah,0ch; asm mov al,0x(color); asm mov cx,x; asm mov dx,y; asm int 10h; } void shape(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned char colorID, unsigned char color ) { int i_x0, i_y0; for(i_x0=x0; i_x0<=x1; i_x0++) { for(i_y0=y0; i_y0<=y1; i_y0++) { point(i_x0, i_y0, colorID,color); } } }