U E D R , A S I H C RSS

Contest Score Board/조현태

트..
.ㅎ
.. .. .
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);
	}
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:00
Processing time 0.0271 sec