/* -*- C++ -*- */ /************************************************************************* * Copyright(c) 1995~2005 Masaharu Goto (root-cint@cern.ch) * * For the licensing terms see the file COPYING * ************************************************************************/ #include #include int a[] = { 1,2,3,4,5,6,7,8,9,10,11 }; short b[8][10] = { { 1,2,3,4,5 }, { 2,3,4,5,6,7,8,9,10,11 }, { 3,4,5,6,7 }, { 4,5,6,7,8 }, { 5,6,7,8,9 }, { 6,7,8,9,10 }, { 7,8,9,10,11 }, { 8,9,10,11 } }; main() { int i,j; test(); for(i=0;i<10;i++) { printf("a[%d]=%d\n",i,a[i]); } for(j=0;j<8;j++) { for(i=0;i<10;i++) { printf("%d ",b[j][i]); } printf("\n"); } test2(); test3(); } test() { short b[][10] = { { 8,9,10,11 }, { 1,2,3,4,5 }, { 2,3,4,5,6,7,8,9,10,11 }, { 3,4,5,6,7 }, { 4,5,6,7,8 }, { 5,6,7,8,9 }, { 6,7,8,9,10 }, { 7,8,9,10,11 }, }; double a[] = { 0.1,1,2,3,4,5,6,7,8,9,10,11,12 }; int i,j; for(i=0;i<10;i++) { printf("a[%d]=%g\n",i,a[i]); } for(j=0;j<8;j++) { for(i=0;i<10;i++) { printf("%d ",b[j][i]); } printf("\n"); } } test2() { #ifdef NEVER int c[3][2][4] = { { 1 ,{2,3,4} }, { {3,4,5,6},{6,7} }, { {4,5,6,7},{7,8,9} } }; #else int c[][2][4] = { { {1} ,{2,3,4} }, { {3,4,5,6},{6,7} }, { {4,5,6,7},{7,8,9} } }; #endif int i,j,k; for(i=0;i<3;i++) { for(j=0;j<2;j++) { for(k=0;k<4;k++) { printf("%d ",c[i][j][k]); } printf(" "); } printf("\n"); } } test3() { char *a[] = { "abc", "def", "hig" }; int i; for(i=0;i<3;i++) printf("%s ",a[i]); printf("\n"); }