3D FPS

1234567890

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  57 Posts :: 2 Stories :: 57 Comments :: 0 Trackbacks

常用链接

留言簿(10)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

放些代码上来 懒得打字:
因为这个东西 有些很不爽

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
//#include "DKcommit.hpp"
template<class T>
struct printT
{    // functor for operator>
    void operator()(const T& _t) const
    {   
        printf("%d ",_t);
        //return true;
    }
};
#define UseThisFile
#ifdef UseThisFile

#define iPageItemCount 15

int PageConcontArray[iPageItemCount];

void GiveSpecDateAtPage(std::vector<int> &vecAllDate, int ipage,int *pIntArray)
{
    std::vector<int>::iterator it;
     if (vecAllDate.size() == 0)
     {
           return ;
     }
    if (vecAllDate.size() > (ipage + 1) * iPageItemCount )
     {
          for (it = vecAllDate.begin() + ipage * iPageItemCount ; it != vecAllDate.begin() + (ipage + 1) * iPageItemCount ;it++)
          {
                 *pIntArray = *it;
                 pIntArray ++;
          }
     }
     else if (vecAllDate.size() < (ipage +1 ) * iPageItemCount
                 && vecAllDate.size() > (ipage) * iPageItemCount )
     {
         for (it = vecAllDate.begin() + ipage * iPageItemCount ; it != vecAllDate.end() ;it++)
         {
             *pIntArray = *it;
             pIntArray ++;
         }
     }
}
//iPageItemCount



void GivedDescDateAtPage(std::vector<int> &vecAllDate, int ipage,int *pIntArray)
{
    std::vector<int>::iterator it;
   

    //int iPageCount = vecAllDate.size() / iPageItemCount;
   
    if (vecAllDate.size() == 0)
    {
        return ;
    }
    if (vecAllDate.size() > (ipage + 1) * iPageItemCount )
    {
        for (it = vecAllDate.end() -1 - (ipage ) * iPageItemCount ; it != vecAllDate.end() - 1  - (ipage +1 ) * iPageItemCount ;it--)
        {
            *pIntArray = *it;
            pIntArray ++;
        }
    }
    else if (vecAllDate.size() <= (ipage +1 ) * iPageItemCount
        && vecAllDate.size() > (ipage) * iPageItemCount )
    {
        //int icount;
        //for (icount = vecAllDate[vecAllDate.size() - vecAllDate.size() % iPageItemCount  - ipage * iPageItemCount] ; icount >= 0  ;icount--)
        //%for (it = vecAllDate.begin(); it != vecAllDate.end() /* - 1*/- ipage * iPageItemCount  ;it++)
        for ( it = vecAllDate.end()  - 1- ipage * iPageItemCount  ;it != vecAllDate.begin()  ;it--)
        {
            //*pIntArray = *(&vecAllDate[icount]);
            *pIntArray = *it;
            pIntArray ++;
        }
        *pIntArray =  *(&vecAllDate[0]);
    }
}


void main()
{
    printf("helloWorld\n");

    std::vector<int> a;
    for (int i = 1; i < 11; i ++)
    {
        a.push_back(i);
    }

    std::for_each(a.begin(),a.end(),printT<int>() );

    printf("\n");

    std::for_each(PageConcontArray,PageConcontArray+10,printT<int>());
    printf("\n");
   

    for (int iPage = 0 ;iPage <= 19;iPage ++)
    {
        printf("This is %d page  :",iPage);
        int a1 = ARRAY_SIZE(PageConcontArray);
        int b2 = sizeof(PageConcontArray)/sizeof(PageConcontArray[0]);
  
        for (int i = 0; i < iPageItemCount ;i++)
        {
            PageConcontArray[i] = 0;
        }
   
       //std::for_each(PageConcontArray,PageConcontArray+iPageItemCount,printT<int>());
       GiveSpecDateAtPage(a,iPage,PageConcontArray);
       std::for_each(PageConcontArray,PageConcontArray+iPageItemCount,printT<int>());
       printf("\n");
    }


    for (int iPage = 0 ;iPage <= 19;iPage ++)
    {
        printf("This is %d page  :",iPage);
        int a1 = ARRAY_SIZE(PageConcontArray);
        int b2 = sizeof(PageConcontArray)/sizeof(PageConcontArray[0]);

        for (int i = 0; i < iPageItemCount ;i++)
        {
            //printf("FFF< %d > sdf",i);
            PageConcontArray[i] = 0;
        }


        //std::for_each(PageConcontArray,PageConcontArray+iPageItemCount,printT<int>());
        GivedDescDateAtPage(a,iPage,PageConcontArray);
        std::for_each(PageConcontArray,PageConcontArray+iPageItemCount,printT<int>());
        printf("\n");
    }




    //std::for_each(PageConcontArray,PageConcontArray+10,printT<int>());

    printf("\n");
    //printf("\n");


   

    getchar();
}


#endif




posted on 2009-02-08 03:17 DK_jims 阅读(214) 评论(2)  编辑 收藏 引用

Feedback

# re: 分页 2009-02-08 03:26 DK_jims
在那一个地方 少了一个等号呀   回复  更多评论
  

# re: 分页 2009-02-08 21:37 DK_jims
发觉自己太无知了 这样容易 错误多多 的程序 是自己写的呀 太屎了  回复  更多评论
  


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理