<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 用鏈表實現(xiàn)的屏幕飄雪程序

          用鏈表實現(xiàn)的屏幕飄雪程序

          作者: 時間:2016-12-01 來源:網(wǎng)絡 收藏
          #include
          #include
          #include
          #define D 1 //雪花下降速度
          COLORREF snowcolor=0x2711EE; //雪花顏色
          COLORREF snowcolor1=0x0000FF; //積雪顏色
          int FENG; //風向風速值
          int MINX; //屏幕X坐標最大值
          int MINY; //屏幕Y坐標最大值
          ////////////////////////////////////////////////////////////////////////////////
          //獲取屏幕分辨率
          int getXY(int *MINX,int *MINY)
          {
          HDC hdc=GetDC(NULL);
          int t=1;
          int x=600;
          int y=600;
          for(;t;)
          {
          if(GetPixel(hdc,x,100)==CLR_INVALID) t=0;
          x++;
          }
          t=1;
          for(;t;)
          {
          if(GetPixel(hdc,100,y)==CLR_INVALID) t=0;
          y++;
          }
          *MINX=x;
          *MINY=y;
          ReleaseDC(NULL, hdc);
          return 0;
          }
          //雪花點屬性結構體
          struct xue {
          int x; //雪花的當前坐標點
          int y;
          COLORREF oldcolor; //當前雪花點的原始顏色值
          int del; //是否刪除該節(jié)點標志值不等于0則刪除此節(jié)點
          int nextx; //將要移動到的坐標點
          int nexty;
          int shudu; //下降速度
          };
          //雪花布局鏈表標準節(jié)點
          struct xhbiao { //此結構體用于創(chuàng)建雪花的布局鏈表
          struct xue xh;
          struct xhbiao *next; //后繼
          struct xhbiao *quet; //前驅
          };
          //初始化單點雪花
          int huaxue (struct xue *xuehua) //函數(shù)功能是初始化一個新的雪花點
          {
          HDC hdc=GetDC(NULL);
          xuehua->y=0;
          xuehua->x=(int)(rand()%MINX);
          xuehua->oldcolor=GetPixel(hdc,xuehua->x,xuehua->y);
          xuehua->shudu=(int)((rand()%10)*D+1);
          xuehua->del=0;
          ReleaseDC(NULL,hdc);
          return 0;
          }
          //創(chuàng)建鏈表
          int link(struct xhbiao **tou,struct xhbiao **wei)
          {
          struct xhbiao *p;
          p=(struct xhbiao*)malloc(sizeof(struct xhbiao));
          huaxue(&p->xh);
          p->next=NULL;
          p->quet=NULL;
          (*tou)=p;
          (*wei)=p;
          return 0;
          }
          //插入節(jié)點
          int linkCHA(struct xhbiao **tou,struct xhbiao **wei)
          {
          if((*tou)!=NULL)
          {
          struct xhbiao *p;
          p=(struct xhbiao*)malloc(sizeof(struct xhbiao));
          huaxue(&p->xh);
          p->next=NULL;
          p->quet=(*wei);
          (*wei)->next=p;
          (*wei)=p;
          }
          return 0;
          }
          //刪除節(jié)點
          int linkDEL(struct xhbiao *del)
          {
          del->quet->next=del->next;
          del->next->quet=del->quet;
          free(del);
          return 0;
          }
          //維護雪堆鏈表清除需要刪除的雪粒節(jié)點
          int linkWUI(struct xhbiao **tou,struct xhbiao **wei)
          {
          struct xhbiao *p;
          p=(*tou);
          for(;p!=NULL;)
          {

          if(p->xh.del!=0)
          {
          if(p==(*tou))
          {
          (*tou)=p->next;
          p->next->quet=NULL;
          free(p);
          }else if(p==(*wei))
          {
          (*wei)=p->quet;
          p->quet->next=NULL;
          free(p);
          }else {
          linkDEL(p);
          }
          }
          p=p->next;
          }
          return 0;
          }
          //物理信息處理

          上一頁 1 2 下一頁

          關鍵詞: 鏈表幕飄雪程

          評論


          技術專區(qū)

          關閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();