
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#define LEN 10 /*进度条长度*/
int main(void) {
float p /*进度条刻度*/
float progLen /*程序总耗时*/
int i, j
progLen = 15.0
for (i=1 i<=progLen i++) {
system ("cls")
p = (i/progLen)*LEN /*计算程序当前进度之于进度条的比例*/
for (j=1 j<=(int)(p+0.5) j++) /*打印已执行刻度*/
printf ("■")
for (j=1 j<=LEN-(int)(p+0.5) j++) /*打印待执行刻度*/
printf ("□")
printf (" %.1f%%", (i/progLen)*100) /*计算程序当前进度的百分比*/
Sleep(150)
}
putchar ('\n')
getch ()
return 0
}
运行结果
程序1:#include "stdio.h"#include <dos.h>
#include <conio.h>
/*去光标函数*/
void no_text_cursor(void)
{
union REGS r
r.h.ah=1
r.h.ch=32
int86(0x10,&r,&r)
}
main()
{
int i
int bfb
char b=219
char c='%'
for(i=1i<=60i++)
{ gotoxy(i,1)/*为了能在进度条和百分比之间变动*/
no_text_cursor()
delay(45000)/*前后两个delay是为了让滚动更好看,流畅*/
printf("%c",b)
delay(45000)
gotoxy(31,2)/*为了能在进度条和百分比之间变动*/
bfb=((i*10)/6)
printf("%d",bfb)
gotoxy(34,2)
printf("%")
}
printf("\nLoading Successful!")
getch()
}程序2:#include<graphics.h>
main()
{
int gdriver=DETECT,gmod,i
/*registerbgidriver(EGAVGA_driver)*/
initgraph(&gdriver,&gmod,"")
setlinestyle(0,0,2)
rectangle(3,215,637,250)
setcolor(RED)
sleep(3)
for(i=0i<632++i)
{
if(i==631)break
line(5+i,216,5+i,249)
delay(2888)
}
getch()
closegraph()
} 以上程序均在TC2.0下通过
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)