[ create a new paste ] login | about

Link: http://codepad.org/qQu3V8Sw    [ raw code | fork ]

C, pasted on Jun 14:
#include <stdio.h>
#include <stdlib.h>

struct SEISEKI {
     char name[50];
     int kokugo;
     int sugaku;
};


void print_score(struct SEISEKI a)
{
	printf( "name:  %s\nkokugo: %d\nsugaku: %d\n", a.name, a.kokugo, a.sugaku );
}

int main( void )
{
	struct SEISEKI	*score;
	int				N;
	int				i;

	scanf("%d", &N);

	score = (SEISEKI*)malloc( sizeof(SEISEKI) * N );
	if( score )
	{
		for (i=0; i<N; i++) {
			scanf("%s %d %d", score[i].name, &score[i].kokugo, &score[i].sugaku);
		}

		for (i=0; i<N; i++) {
			print_score( score[ i ] );
		}

		free( score );
	}

	return 0;
}


Create a new paste based on this one


Comments: