- 论坛徽章:
- 0
|
本帖最后由 AD8018 于 2011-08-29 11:18 编辑
好吧,放段很没深度的代码吧。
代码输出结果
n1[] = 0 3 6 9 12
n2[] = 15 14 13 12 11 10 9 8 7 6
a1[] = 1 2 3 4 5
a2[] = 1 2 3 4 5 6 7 8 9
a1, a2是楼主1楼要定义的a
头文件mfor.h在60楼
- #include <stdio.h>
- #include "mfor.h"
- #define X1(n,MFOR) MFOR n*3,
- const int n1[5] =
- {
- FORA4(X1)
- };
- #define X2(n,MFOR) (n+6), MFOR
- const int n2[10] =
- {
- FORA9(X2)
- };
- #define JOIN(a,b) a##b
- #define X_An(n,MFOR) (n == 0 ? 1 : MFOR + 1)
- #define A(n) JOIN(FORA,n)(X_An)
- #define X_a(n,MFOR) MFOR A(n),
- const int a1[] =
- {
- FORB4(X_a)
- };
- const int a2[] =
- {
- FORB8(X_a)
- };
- int main()
- {
- int i;
- printf("n1[] = ");
- for(i = 0; i < sizeof(n1) / sizeof(n1[0]); ++i)
- printf("%d ", n1[i]);
- printf("\n");
- printf("n2[] = ");
- for(i = 0; i < sizeof(n2) / sizeof(n2[0]); ++i)
- printf("%d ", n2[i]);
- printf("\n");
- printf("a1[] = ");
- for(i = 0; i < sizeof(a1) / sizeof(a1[0]); ++i)
- printf("%d ", a1[i]);
- printf("\n");
- printf("a2[] = ");
- for(i = 0; i < sizeof(a2) / sizeof(a2[0]); ++i)
- printf("%d ", a2[i]);
- printf("\n");
- return 0;
- }
复制代码 |
|