中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > C/C++
人月团圆趣味程序:用C实现的爱情宣言
作者:Sabine  时间:2006-10-04 12:25 出处:ccidnet.com 责编:月夜寒箫
              摘要:人月团圆趣味程序:用C实现的爱情宣言

祝有情人团圆

 

#include "stdio.h"
            #include "graphics.h"
            #include "time.h"
            #include "math.h"
            #define N 2
            #define TIME 0.8/*微粒的的运动时间,TIME/步,每一步长为25个单位*/
            void *buf[N];
            struct
            {
            int x,y;
            } lizi[]={{0,0},{75,75}};
            void alter_place_lizi(int *x,int *y,int key)/*根据随机方向改变粒子的方位*/
            {
            switch(key)
            {case 0:
            case 1:
            case 2:*x-=25;break;
            case 4:
            case 5:
            case 6:*x+=25;break;
            }
            switch(key)
            { case 0:
            case 7:
            case 6:*y-=25;break;
            case 2:
            case 3:
            case 4:*y+=25;break;
            }
            if(*x<0) *x=0;
            if(*x>250) *x=250;
            if(*y<0) *y=0;
            if(*y>250) *y=250;
            }
            void make_graphics()/*画方框*/
            {int i,j,driver=VGA,mode=VGAHI;
            initgraph(&driver,&mode,"");
            setbkcolor(YELLOW);
            cleardevice();
            setcolor(LIGHTRED);
            setlinestyle(0,0,1);
            for(i=0;i<=10;i++)
            line(0,25*i,250,25*i);
            for(i=0;i<=10;i++)
            line(25*i,0,25*i,250);
            }void make_circle(int x,int y,int n)/*根据提供的离子所在方位画圆*/
            {
            int size;
            setcolor(LIGHTRED);
            setlinestyle(0,0,1);
            setfillstyle(1,10);
            circle(x+25/2,y+25/2,25/2);
            floodfill(x+25/2,y+25/2,12);
            size=imagesize(x,y,x+25,y+25);
            buf[n]=(void *)malloc(size);/*保存每一个圆*/
            }
            void sport(int *x,int *y)/*粒子的运动*/
            {
            time_t starttime,endtime;
            int seed=0,i,j;
            int key;
            char s[300];
            int t=1;
            srand(seed);
            /*保存现场图形*/
            for(i=0;i getimage(x[i],y[i],x[i]+25,y[i]+25,buf[i]);
            cleardevice();/*清除*/
            setbkcolor(BLUE);
            cleardevice();
            setviewport(50, 50, 590, 430, 1); /*定义一个图形窗口*/
            setfillstyle(1, 2); /*绿色以实填充*/
            setcolor(YELLOW);
            rectangle(0, 0,590, 230);
            floodfill(50, 50, 14);
            setcolor(12);
            settextstyle(1, 0, 8); /*三重笔划字体, 水平放大8倍*/
            outtextxy(20, 20, "I miss you");
            setcolor(11);
            settextstyle(1, 0, 4); /*三重笔划字体, 水平放大4倍*/
            outtextxy(100, 100, "where are you");
            time(&starttime);
            time(&endtime);
            for(;difftime(endtime,starttime)<=2.0;time(&endtime));
            setbkcolor(YELLOW);
            cleardevice();
            setcolor(LIGHTRED);
            setlinestyle(0,0,1);
            while(t)
            {
            if(fabs(x[0]-x[1])==25&&fabs(y[0]-y[1])==25)
            {for(i=0;i {key=rand()%8;
            alter_place_lizi(&x[i],&y[i],key);
            }
            }
            else if(fabs(x[0]-x[1])==25||fabs(y[0]-y[1])==25)
            {key=rand()%8;
            for(i=0;i alter_place_lizi(&x[i],&y[i],key);t++;
            }
            else
            {for(i=0;i {key=rand()%8;
            alter_place_lizi(&x[i],&y[i],key);
            }
            }
            for(i=0;i putimage(x[i],y[i],buf[i],COPY_PUT);
            /*界面维持0.5秒钟*/
            time(&starttime);
            time(&endtime);
            for(;difftime(endtime,starttime)<=TIME;time(&endtime));
            for(i=0;i getimage(x[i],y[i],x[i]+25,y[i]+25,buf[i]);
            cleardevice();
            switch(t)
            {case 1:setcolor(t);
            settextstyle(1, 0, 2); /*三重笔划字体, 水平放大4倍*/
            outtextxy(t, t, "I am tired to look after you"); delay(1e10);
            break;
            case 2:setcolor(t);
            settextstyle(1, 0, 2); /*三重笔划字体, 水平放大4倍*/
            outtextxy(t, t, "could you wait for me please?");delay(1e10);
            break;
            case 3:setcolor(t);
            settextstyle(1, 0, 2); /*三重笔划字体, 水平放大4倍*/
            outtextxy(t, t, "I can not catch up with you");delay(1e10); break;
            case 4:setcolor(t);
            settextstyle(1, 0, 2); /*三重笔划字体, 水平放大4倍*/
            outtextxy(t, t, "you walk so quckily");delay(1e10); break;
            case 5:setcolor(t);
            settextstyle(1, 0, 2); /*三重笔划字体, 水平放大4倍*/
            outtextxy(t, t, "I will not give up and I believe I can keep up with you one day");delay(1e10); break;
            case 6:setcolor(t);
            settextstyle(1, 0, 2); /*三重笔划字体, 水平放大4倍*/
            outtextxy(t, t, "I can not help stoping as result of your beauty");delay(1e10); break;
            default:setcolor(t);
            settextstyle(1, 0, 5); /*三重笔划字体, 水平放大4倍*/
            outtextxy(t-3, t-3, "I will go with you forever");
            }
            }
            }
            main()
            {time_t starttime,endtime;
            int i,j;
            int x[N],y[N],t[N];
            make_graphics();
            for(i=0;i make_circle(lizi[i].x,lizi[i].y,i);
            time(&starttime);
            time(&endtime);
            for(;difftime(endtime,starttime)<=1.0;time(&endtime));
            for(i=0;i{x[i]=lizi[i].x;
            y[i]=lizi[i].y;
            }
            sport(x,y);
            }
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有