/*
第2種情報処理技術者試験 平成5年度・春期・午後 問13
BohYoh Shibata PREPARATION
*/
#include <stdio.h>
#include <string.h>
main()
{
static struct {
char ccode[7];
int count;
long gtime;
} tbl[1000];
FILE *fp;
char ucode[14], date[7];
int utime, ntbl, cmp, k, m;
long min, charge;
fp = fopen("is_log", "r");
ntbl = 0;
while (fscanf(fp, "%s%s%d", ucode, date,
&utime ) != EOF) {
cmp = 1;
for (k = 0; k < ntbl; k++)
if ((cmp = strncmp(tbl[k].ccode, ucode, 6)) >= 0)
break;
if (cmp == 0) {
tbl[k].count++;
tbl[k].gtime += utime;
} else {
for (m = ntbl; m > k ; m--)
tbl[m] = tbl[ m - 1 ];
strncpy(tbl[k].ccode, ucode, 6);
tbl[k].ccode[6] = '\0';
tbl[k].count = 1;
tbl[k].gtime = utime;
ntbl++;
}
}
fclose(fp);
printf("Information Service Account Report\n");
printf(" Client Access Time Charge\n");
printf(" Code Count (min) (yen)\n");
for (k = 0; k < ntbl; k++) {
min = (tbl[k].gtime + 59 ) / 60;
charge = min * 50;
printf("%9s%7d%7ld%8ld\n",
tbl[k].ccode, tbl[k].count, min, charge);
}
}