| | |
|
¿À´Ã |
186 |
¾îÁ¦ |
148 |
ÃÖ´ë |
1,112 |
Àüü |
353,813 |
|
|
| | |
|
ÀÛ¼ºÀÏ : 14-11-29 09:56
°è¸®Á÷ 1200Á¦ 1065¹ø ´äº¯
|
|
±Û¾´ÀÌ :
¿î¿µÀÚ
Á¶È¸ : 5,477
|
C¾ð¾îÀÇ ±¸Á¶Ã¼ÀÔ´Ï´Ù..
±¸Á¶Ã¼´Â ·¹Äڵ带 ¸»ÇÕ´Ï´Ù..
ÀϹݺ¯¼ö´Â int, float, char¿Í º¯¼ö¸íÀ» ÁÖ¸é µÇÀݾƿä..
ÀÌ°Ç ÀÌ¹Ì ÄÄÆÄÀÏ·¯¿¡¼ ±× ±¸Á¶¸¦ °®°í ÀÖ´Â °Ì´Ï´Ù..
int a;
float b;
char c; --- ±âÁ¸ ¹æ½Äµé
±×·±µ¥..
³ª´Â »õ·Î¿î ³ª¸¸ÀÇ º¯¼ö¸¦ ¸¸µé¾î »ç¿ëÇÏ°í ½Í¾î¿ä...
·¹ÄÚµå¿Í °°ÀÌ
[bun][name][jumsu] ----> ÀÌ°ÍÀ» ÇÑ ¹ø¿¡ ¼±¾ðÇÏ°í ½ÍÀº °Ì´Ï´Ù..
STUDENT a; Çϸé À§¿Í°°ÀÌ 3°³ÀÇ Ç׸ñÀ» °®´Â º¯¼ö·Î¿ä...
±×·³ ¼±¾ðÇØ º¸Áö¿ä...
struct aa { int bun,
char name[20];
int jumsu;
}; // ±¸Á¶¸¦ ¸¸µç °Ì´Ï´Ù..
struct aa a;¸¦ ¼±¾ðÇصµ µÇÁö¸¸...
struct aa¸¦ STUDENT·Î ¹Ù²Ü²²¿ä..
#define STUDENT struct aa ...·Î ġȯÇÕ´Ï´Ù..
±×·¯¸é..³ª¸¸ÀÇ ±¸Á¶¸¦ °®´Â ¿¹¾à¾î ¼öÁØÀÇ Å¸ÀÔ¼±¾ðÀÌ ¸¸µé¾î Áø°ÅÁö¿ä...
ÀÌÁ¦´Â
STUDNET a; ·Î ¼±¾ðÇÏ°í..
´ÙÀ½°ú °°ÀÌ »ç¿ëÇÒ ¼ö ÀÖ¾î¿ä..
a.bun=1;
strcpy(a.name,"È«±æµ¿")'
a.jumsu = 100;
printf("%d %s %d \n", a.bun, a.name, a.jumsu);
-------------------
ÀÌÁ¦´Â ¹®Á¦Ã³·³...¸µÅ©µå¸®½ºÆ®ÀÇ ±¸Á¶¸¦ ¸¸µé¾î ¿¬°áÇÏ°í ½Í½À´Ï´Ù..
³ª¸¸ÀÇ ±¸Á¶¸¦ ¸¸µé¾î¾ßÁö¿ä...
±×·±µ¥ ³ª¸¸ÀÇ ±¸Á¶¿¡´Â ³ª ÀÚ½ÅÀ» °¡¸®Å°´Â Æ÷ÀÎÅÍ º¯¼ö°¡ Æ÷ÇԵǾúÀ¸¸é ÇÕ´Ï´Ù..
struct bb { int data,
struct bb *node;
}; // ±¸Á¶¸¦ ¸¸µç °Ì´Ï´Ù..[data][node]
ÀÌÁ¦´Â ¸Þ¸ð¸®¿¡¼ ³» °¡ ¼±¾ðÇÑ ¸¸ÅÀÇ ¸Þ¸ð¸®¸¦ ¶°¿Í¾ßÁö¿ä...
±× ÇÔ¼ö°¡ malloc(Å©±â) ÇÔ¼öÀÔ´Ï´Ù..
malloc()ÀÇ Àμö·Î ¸Þ¸ð¸®¿¡¼ ¶°¿Ã Å©±â¸¦ ÁöÁ¤ÇؾßÇϴµ¥...
Áö±ÝÀ¸·Î¼´Â int°¡ 2¹ÙÀÌÆ®ÀÎÁö..4¹ÙÀÌÆ®ÀÎÁö ¸ð¸£´Ï±î..
sizeof()¸¦ ÀÌ¿ëÇÕ´Ï´Ù..
malloc(sizeof(struct bb)); // ³»°¡ ¼±¾ðÇÑ ±¸Á¶ÀÇ ¹ÙÀÌÆ® ¸¸ÅÀ» ¸Þ¸ð¸®¿¡¼ ÆÛ¿É´Ï´Ù..
¶ÇÇÑ ±× ŸÀÔ À¯ÇüÀ» ±¸Á¶Ã¼ Æ÷ÀÎÅÍ·Î °Á¦ ÁöÁ¤ÇØ¾ß ÇÕ´Ï´Ù..
(struct bb *) malloc(sizeof(struct bb));
±×¸®°í ÇÒ´ç¹ÞÀº ¸Þ¸ð¸®ÀÇ Æ÷ÀÎÅ͸¦ Æ÷ÀÎÅÍ º¯¼ö p°¡ °¡¸®Å°°Ô ÇÕ´Ï´Ù..
p=(struct bb *) malloc(sizeof(struct bb));
-------------- ¿©±â±îÁö ÀÌÇظ¦ ¸ÕÀú ÇؾßÇÕ´Ï´Ù..
ÀÌÁ¦ Ã¥¿¡ ÀÖ´Â ¹®Á¦·Î ¹æÇâÀ» Ʋ¾î º¼²²¿ä..
Ã¥¿¡´Â
sturct list¸¦ Àü sturct bb·Î »ç¿ëÇÑ °Å±¸¿ä..
#define LIST struct list ¸¦
#define LIST struct bb·Î »ý°¢ÇÏ½Ã¸é µË´Ï´Ù.. bb³ª list´Â »ç¿ëÀÚ°¡ ÀÓÀÇ·Î »ç¿ëÇÒ ¼ö ÀÖ´Â tag·Î
¿©·¯°³ÀÇ ±¸Á¶¸¦ ¼±¾ðÇÒ °æ¿ì¿¡ ±¸ºÐÀÌ ÇÊ¿äÇÑ »ç¿ëÀÚ Á¤ÀǾîÀÔ´Ï´Ù..
LIST·Î defineÇß´Ù¸é..
¸ðµÎ
p=(LIST *) malloc(sizeof(LIST)); »ç¿ëÇÒ ¼öÀÖ´Â °ÅÁö¿ä...
ÀÌÁ¦´Â LIST´Â ³ª¸¸ÀÌ »ç¿ëÇÏ´Â ±¸Á¶Ã¼ ¼±¾ð ¿¹¾à¾î ÀÔ´Ï´Ù..
LIST Æ÷ÀÎÅÍ º¯¼ö¸¦ µÎ°³ ¼±¾ð Çß½À´Ï´Ù..
LIST *head, *p; // head´Â ³ëµå°¡ ¿©·¯°³ »ý±æ ¼ö ÀÖÀ¸¹Ç·Î óÀ½ À§Ä¡¸¦ °¡¸®Å°°Ô Çϵµ·Ï »ç¿ë..
head=(LIST *) malloc(sizeof(LIST)); // ÇϳªÀÇ ³ëµå¸¦ ¸Þ¸ð¸®¿¡¼ ¶°¼..head°¡ °¡¸®Å°°Ô Çß½À´Ï´Ù..
head->data = 10; // »õ·Î ÇÒ´ç¹ÞÀº ¸Þ¸ð¸®ÀÇ data ºÎºÐ¿¡ 10À» ±â¾ï½ÃÄ×½À´Ï´Ù..
p=(LIST *) malloc(sizeof(LIST)); // µÎ¹ø° ³ëµå¸¦ ¸Þ¸ð¸®¿¡¼ ¶°¼..p°¡ °¡¸®Å°°Ô Çß½À´Ï´Ù..
p->data = 20; // µÎ¹ø°·Î ÇÒ´ç¹ÞÀº ¸Þ¸ð¸®ÀÇ data ºÎºÐ¿¡ 20À» ±â¾ï½ÃÄ×½À´Ï´Ù..
head->node = p; //ù¹ø° ³ëµå¿Í µÎ¹ø° ³ëµå¸¦ ¿¬°áÇß½À´Ï´Ù..
p=(LIST *) malloc(sizeof(LIST)); // ¼¼¹ø° ³ëµå¸¦ ¸Þ¸ð¸®¿¡¼ ¶°¼.. ´Ù½Ã p°¡ °¡¸®Å°°Ô Çß½À´Ï´Ù..
p->data = 30; // ¼¼¹ø°·Î ÇÒ´ç¹ÞÀº ¸Þ¸ð¸®ÀÇ data ºÎºÐ¿¡ 20À» ±â¾ï½ÃÄ×½À´Ï´Ù..
head->node->node = p; //µÎ¹ø°¿Í ¼¼¹ø° ³ëµå¸¦ ¿¬°áÇß½À´Ï´Ù..
printf("%d", head->node->node->data); //¼¼¹ø° ³ëµåÀÇ 30ÀÌ Ãâ·Â µË´Ï´Ù..
Áö±ÝÀÇ ¼³¸íÀÌ ÀÌÇØ°¡ ¾ÈµÇ½Ã¸é Àüȸ¦ ÇÏ¼Å¾ß ÇÕ´Ï´Ù..
¿¬±¸ÇØ º¸¼¼¿ä
LIST´Â struct bb·Î LIST·Î define Çϼŵµ µÇ°í ¾ÈÇϼŵµ µË´Ï´Ù..
|
|
|