其实我那个主要是因为要4个一行,不然也不会这么长,而且,程序是有错误的!!!但我查不出来了。。
#define PIG_NUMBER_ONE(a,b,c) printf("%d%d%d\n",a,b,c); #define PIG_NUMBER_TWO(a,b,c) PIG_NUMBER_ONE(a,b,c)\ PIG_NUMBER_ONE(a,c,b)\ PIG_NUMBER_ONE(b,a,c)\ PIG_NUMBER_ONE(b,c,a)\ PIG_NUMBER_ONE(c,b,a)\ PIG_NUMBER_ONE(c,a,b) #define PIG_NUMBER_THREE(a,b) PIG_NUMBER_ONE(a,a,b)\ PIG_NUMBER_ONE(a,b,a)\ PIG_NUMBER_ONE(b,a,a) int main(){ for(unsigned int a=0;a<10;a++){ if(a==3) continue; for(unsigned int b=a;b<10;b++){ if(b==3&&b==0) continue; if((a+b)%3==0){ PIG_NUMBER_TWO(3,b,a) } } } PIG_NUMBER_THREE(0,3) PIG_NUMBER_THREE(3,6) PIG_NUMBER_THREE(3,9) PIG_NUMBER_ONE(3,3,3) return 0; }
#define PIG_NUMBER_ONE(a,b,c) printf("%s\n%s\n%s\n%s\n%s\n%s\n",PIG_NUMBER_TWO(a,b,c),PIG_NUMBER_TWO(a,c,b)\ ,PIG_NUMBER_TWO(b,c,a),PIG_NUMBER_TWO(c,b,a),PIG_NUMBER_TWO(b,a,c),PIG_NUMBER_TWO(c,a,b)); #define PIG_NUMBER_TWO(a,b,c) #a#b#c #define PIG_NUMBER_THREE(a,b,c) printf("%d\n%d\n%d\n",PIG_NUMBER_FOUR(a,b,c),PIG_NUMBER_FOUR(a,c,b),PIG_NUMBER_FOUR(c,a,b)); #define PIG_NUMBER_FOUR(a,b,c) a##b##c #define PIG_NUMBER_FIVE(a,b,c) printf("%s\n",#a#b#c); int _tmain(int argc, _TCHAR* argv[]) { PIG_NUMBER_ONE(0,6,3) PIG_NUMBER_ONE(0,9,3) PIG_NUMBER_ONE(1,2,3) PIG_NUMBER_ONE(1,5,3) PIG_NUMBER_ONE(1,8,3) PIG_NUMBER_ONE(2,4,3) PIG_NUMBER_ONE(2,7,3) PIG_NUMBER_ONE(4,5,3) PIG_NUMBER_ONE(4,8,3) PIG_NUMBER_ONE(5,7,3) PIG_NUMBER_ONE(6,6,3) PIG_NUMBER_ONE(6,9,3) PIG_NUMBER_THREE(3,3,6) PIG_NUMBER_THREE(3,3,9) PIG_NUMBER_FIVE(3,3,3) PIG_NUMBER_FIVE(0,3,3) PIG_NUMBER_FIVE(3,0,3) PIG_NUMBER_FIVE(3,3,0) return 0; }