#if 宏处理循环双流水

#define SIZE 5

int a[SIZE] = {1, 2, 3, 4, 5};

#if SIZE & 1
 //SIZE是奇数
 int s = a[0];
 for (int i = 1; i < SIZE; i += 2)
  {
   s += a[i];
   s += a[i + 1];
  }
#else
 //SIZE是偶数
 int s = 0;
 for (int i = 0; i < SIZE; i += 2)
  {
   s += a[i];
   s += a[i + 1];
  }
#endif


 

你可能感兴趣的:(#if 宏处理循环双流水)