#include<stdio.h>
#define N 500

main(int argc,char *argv[])
{
        char    dai[N+1][N+1],kyokan[N+1][N+1],heya[N+1][N+1],you[N+1][N+1];
        char    gen[N+1][N+1],gakki[N+1][N+1],kaisi[N+1][N+1],s[N+1],s2[N+1],s3[N+1];
        int     i,j,h,count;

        FILE *fin=fopen(argv[1],"r");
        if(argc!=2)
                {
                printf("プログラム名　対象データファイル\nと書いてください\n例 a.out jugyo.dat\n");
                exit(1);
                }

        h=1;

while(fgets(s,500,fin) != NULL){
                sscanf(s,"%s %s %s %s %s %s %s",dai[j],kaisi[j],gakki[j],you[j],gen[j],kyokan[j],heya[j]);
                ++j;
        }
        
        count=j;
        
        printf("<html><head><title>９９年度時間割り</title></head>\n");
        for(h=1;h<=2;++h){
                printf("<h2>%d 学期</h2> <table border>\n",h);
                printf("<tr><td><th>月 <th>火 <th>水 <th>木 <th>金\n");
                s3[0]='0'+h;

                for(i=1;i<=5;++i){
                        s2[0]='0'+i;
                        printf("<tr><th>%d\n",i);

                        printf("<td><!--月-->\n");
                        for(j=0;j<count;++j){
                                if(strcmp("月",you[j])==0 && strcmp(s3,gakki[j])==0 && strcmp(s2,gen[j])==0)
                                printf("%s (%s)<br> %s %s<hr>\n",dai[j],kaisi[j],kyokan[j],heya[j]);
                        }

                        printf("<td><!--火-->\n");
                        for(j=0;j<count;++j){
                                if(strcmp("火",you[j])==0 && strcmp(s3,gakki[j])==0 && strcmp(s2,gen[j])==0)
                                printf("%s (%s)<br> %s %s<hr>\n",dai[j],kaisi[j],kyokan[j],heya[j]);
                        }

                        printf("<td><!--水-->\n");
                        for(j=0;j<count;++j){
                                if(strcmp("水",you[j])==0 && strcmp(s3,gakki[j])==0 && strcmp(s2,gen[j])==0)
                                printf("%s (%s)<br> %s %s<hr>\n",dai[j],kaisi[j],kyokan[j],heya[j]);
                        }

                        printf("<td><!--木-->\n");
                        for(j=0;j<count;++j){
                                if(strcmp("木",you[j])==0 && strcmp(s3,gakki[j])==0 && strcmp(s2,gen[j])==0)
                                printf("%s (%s)<br> %s %s<hr>\n",dai[j],kaisi[j],kyokan[j],heya[j]);
                        }

                        printf("<td><!--金-->\n");
                        for(j=0;j<count;++j){
                                if(strcmp("金",you[j])==0 && strcmp(s3,gakki[j])==0 && strcmp(s2,gen[j])==0)
                                printf("%s (%s)<br> %s %s<hr>\n",dai[j],kaisi[j],kyokan[j],heya[j]);
                        }


                }
        printf("</table>\n");
        }

        printf("</body></html>\n");


}


