放些代码上来 懒得打字:
因为这个东西 有些很不爽
#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