ëŠ�ë‚€ì � ë°� 설명 ¶
ì�´ë²ˆ ë¬¸ì œì�˜ í’€ì�´ì�˜ ìž�료구조는 ë§�í�¬ë“œ 리스트..
ì—시 나ì�˜ ìž�료구조ì�˜ 기본ì�€ ë°°ì—´ 아니면 ë§�í�¬ë“œ 리스트 ì�¸ê²ƒ 같다.ã…Ž
사실 배열로 ìž‘ì„±í•˜ë ¤ê³ í–ˆìœ¼ë‚˜.. ì™ ì§€ ë§�í�¬ë“œ 리스트가 ë�” 어울릴 것 ê°™ê³ .. ë°°ì—´ì�˜ 장ì �ì�„ 살릴 수 ì—†ì�„ 것 같아서 ë§�í�¬ë“œë¦¬ìŠ¤íŠ¸ë¡œ 했다.
ë¬¸ì œë¥¼ 다 ì�½ì–´ë�„ ìž…ë ¥ë�˜ëŠ” ìž�료ì�˜ 2번째가 무엇ì�„ 뜻하는지 ì�´í•´í•˜ì§€ 못하는 불ìƒ�사..(;;)ê°€ 있었으나 몰ë�¼ë�„ 잘 풀어진다는 특징ì�´..;;;
ë�.. ì�¼ë‹¨ì�€ 테스트ë�„ 잘 ë�˜ë‹ˆ 좋ì�€ê²Œ 좋ì�€ê±°ë�¼ê³ ìƒ�ê°�하며 ë„˜ì–´ê°€ê² ë‹¤..후후후..ã…Ž
그럼 좋�하루 �시길..ㅎ
ì—시 나ì�˜ ìž�료구조ì�˜ 기본ì�€ ë°°ì—´ 아니면 ë§�í�¬ë“œ 리스트 ì�¸ê²ƒ 같다.ã…Ž
사실 배열로 ìž‘ì„±í•˜ë ¤ê³ í–ˆìœ¼ë‚˜.. ì™ ì§€ ë§�í�¬ë“œ 리스트가 ë�” 어울릴 것 ê°™ê³ .. ë°°ì—´ì�˜ 장ì �ì�„ 살릴 수 ì—†ì�„ 것 같아서 ë§�í�¬ë“œë¦¬ìŠ¤íŠ¸ë¡œ 했다.
ë¬¸ì œë¥¼ 다 ì�½ì–´ë�„ ìž…ë ¥ë�˜ëŠ” ìž�료ì�˜ 2번째가 무엇ì�„ 뜻하는지 ì�´í•´í•˜ì§€ 못하는 불ìƒ�사..(;;)ê°€ 있었으나 몰ë�¼ë�„ 잘 풀어진다는 특징ì�´..;;;
ë�.. ì�¼ë‹¨ì�€ 테스트ë�„ 잘 ë�˜ë‹ˆ 좋ì�€ê²Œ 좋ì�€ê±°ë�¼ê³ ìƒ�ê°�하며 ë„˜ì–´ê°€ê² ë‹¤..후후후..ã…Ž
그럼 좋�하루 �시길..ㅎ
소스 ¶
~cpp
#include <stdio.h>
#include <iostream>
struct datas{
int team_number;
int score;
int used_time;
datas* prv;
datas* next;
};
void input_data();
datas* such_and_malloc_point(int);
void print_data();
void free_data();
datas* start_point=NULL;
datas* end_point=NULL;
const int WRONG_TIME=20;
void main()
{
int test_number;
printf("몇번 테스트 í•˜ì‹œê² ìŠµë‹ˆê¹Œ?");
scanf ("%d",&test_number);
while (test_number!=0)
{
printf("\n");
input_data();
print_data();
free_data();
--test_number;
}
}
void input_data()
{
printf("ë�°ì�´í„°ë¥¼ ìž…ë ¥í•´ 주세요.맨 앞ì�´ 0ì�€ 취소\n");
while(1)
{
int input_team_number, input_temp, input_time; char input_e;
printf(">>");
scanf("%d %d %d %c",&input_team_number, &input_temp, &input_time, &input_e);
if (input_team_number==0)
break;
datas* temp_point;
if ('C'==input_e)
{
temp_point=such_and_malloc_point(input_team_number);
++temp_point->score;
temp_point->used_time+=input_time;
}
else if ('I'==input_e)
{
temp_point=such_and_malloc_point(input_team_number);
temp_point->used_time+=WRONG_TIME;
}
}
}
datas* such_and_malloc_point(int target_team_number)
{
datas* temp_point=start_point;
while (temp_point!=NULL)
{
if (target_team_number==temp_point->team_number)
return temp_point;
temp_point=temp_point->next;
}
temp_point=(datas*)malloc(sizeof(datas));
temp_point->prv=end_point;
if (start_point==NULL)
start_point=temp_point;
else
end_point->next=temp_point;
end_point=temp_point;
temp_point->team_number=target_team_number;
temp_point->score=0;
temp_point->used_time=0;
temp_point->next=NULL;
return temp_point;
}
void print_data()
{
datas* temp_point=start_point;
printf("참가 팀 번호\t푼 ë¬¸ì œ 개수\t누ì �ë�œ 시간 벌ì �\n");
while (temp_point!=NULL)
{
printf("%d\t%d\t%d\n",temp_point->team_number,temp_point->score,temp_point->used_time);
temp_point=temp_point->next;
}
}
void free_data()
{
datas* temp_point=start_point;
if (temp_point!=NULL)
{
while (temp_point->next!=NULL)
{
temp_point=temp_point->next;
free(temp_point->prv);
}
free(temp_point);
}
}










