느낀 및 명 ¶
문 료구는 링드 리..
나 료구 기본 배 면 링드 리 것 같다.ㅎ
배로 려고 나.. 링드 리가 더 릴 것 같고.. 배 릴 것 같 링드리로 다.
문를 다 력되는 료 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);
}
}










