느낀 및 명 ¶
번 문 료는 링 리..
료 본 배 면 링 리 .ㅎ
배 .. 링 리 더 릴 .. 배 릴 링리 .
문를 는 료 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);
}
}










