/* 2013³â °í±Þ C ÇÁ·Î±×·¡¹Ö Áß°£ °í»ç Çйø : ¼º¸í : ´ÙÀ½ ÇÁ·Î±×·¥µéÀÇ Ãâ·ÂÀ» ½á¶ó. ÁÖÀÇ »çÇ× (1): ½ÃÇèÁö¿¡ Àý´ë·Î ³«¼­ÇÏÁö ¸»°Í ÁÖÀÇ »çÇ× (2): ¹®Á¦µéÀ» Ç® ¶§ ¸ðµç ÇÁ·Î±×·¥¿¡ ÀÖ´Â data º¯¼öÀÇ °ªÀ» ¾Æ·¡ °ªÀ¸·Î ´ëÄ¡ÇÑ ÈÄ¿¡ ¹®Á¦¸¦ Ç®°Í. int data[5] = { 1, 2, 3, 4, 5 }; =>> { } */ /* 1. ´ÙÀ½ ÇÁ·Î±×·¥ÀÇ Ãâ·ÂÀ» ½á¶ó. */ #include int what(int x,int n) { if (x/10 == 0) return x; if (n/2*2 == n) { return what(x/10, n-1); } else { int i = 0; int y = 1; for(i = 1; i < n; i++) { y = y * 10; } x = x - x/y*y; return what(x,n-1); } } main() { int data[5] = { 1, 2, 3, 4, 5 }; int i,x,y; x = 0; for(i = 0; i < 5; i++) { x = 10*x + data[i]; } y = what(x,5); printf("%d\n",y); }