C语言比较有意思的几个小程序

#include < conio.h >

main()
{
    
int i;
    
char *s[]={"BLACK","BLUE","GREEN","CYAN",
    
"RED","MAGENTA","BROWN","LIGHTGRAY",}
;
    textmode(C80);
    textbackground(
0);
    clrscr();
    
for(i=1;i<8;i++)
    
{
        window(
10+i*5,5+i,30+i*5,15+i);
        
/*函数名: window 
        功 能: 定义活动文本模式窗口
        用 法: void window(int left, int top, int right, int bottom); 
        函数中形式参数(int left,  int top)是窗口左上角的坐标,
        (int right, int  bottom)是窗口的右下角坐标, 
        
*/

        textbackground(i);
        clrscr();
        textcolor(
7+i);
        
if(i%2 == 0)
        highvideo();
        
else lowvideo();
        cputs(s[i]);
    }

    getch();

}

 以上程序显示四个层叠的彩色窗口

 

#include < graphics.h >
#include
< time.h >

main()
{
    
int graphdriver = VGA;
    
int graphmode = VGAMED;
    
int i,height,width
    ;
    unsigned 
char *temp="Welcome";
    initgraph(
&graphdriver,&graphmode,"");/*/图形系统初始化函数*/
    settextjustify(LEFT_TEXT,TOP_TEXT); 
/*文本输出位置函数*/
    cleardevice();
    
for(i=1;i<5;i++)
    
{
        setvisualpage(i
-1);
        setactivepage(i);
        cleardevice();   
/*清除图形屏幕*/
        setcolor(
12);
        setbkcolor(BLUE);
        settextstyle(TRIPLEX_FONT,HORIZ_DIR,i); 
/*设置用三倍画笔,水平放置,放大I倍*/
        width
=textwidth(temp);
        height
=textheight(temp);
        outtextxy((
639-width)/2,175-height/2,temp);/*在指定位置输出字符串*/
        setvisualpage(i);
        setactivepage(i
-1);
        cleardevice();
        setcolor(
10);
        settextstyle(TRIPLEX_FONT,HORIZ_DIR,i
++);
        width
=textwidth(temp);
        height
=textheight(temp);
        outtextxy((
639-width)/2,175-height/2,temp);
        system(
"pause");
    }

        getch();
        closegraph();
}
这个家伙没啥效果,理论上是应该有字符颜色的不同变化形成动画效果,但是只有字符显示没有动画,..

你可能感兴趣的:(C/C++,语言,c,图形,include,system,活动)