/* 2006 ³âµµ C++ ±â¸»°í»ç ¼º¸í ( ) Çйø ( ) ¹®Á¦ Key ( ) */ /* ´ÙÀ½ ¸ðµç ¹®Á¦¿¡ ´ëÇÏ¿© 12345 ¼ö¸¦ Àڱ⠹®Á¦ Key ¼ö·Î ¹Ù²Û ÈÄ ¹®Á¦¸¦ Ǫ½Ã¿À. */ /* ¹®Á¦Áö¿¡ ³«¼­ÇÏÁö ¸»°Í */ /* 1. ´ÙÀ½ ÇÁ·Î±×·¥ÀÇ Ãâ·ÂÀ» ½á¶ó. */ #include class Point { int &x; int y; int *z; public: Point(int &a,int b,int *c) : x(a), y(b), z(c) // µ¥ÀÌÅÍ ¸â¹ö¸¦ ÃʱâÈ­ÇÏ´Â ¹®¹ý { } void swap() { *z = x; y = *z; x = y; } }; void main() { int data[5] = { 1, 2, 3, 4, 5 }; // ¿©±â¸¦ ¹Ù²Ü °Í Point p1(data[0],data[1],&data[2]); Point p2(data[2],data[3],&data[4]); p1.swap(); p2.swap(); for(int i = 0; i < 5; i++) printf("%d ",data[i]); }