#include <stdio.h>
#include <stdlib.h>
#define P 25
#define Q 43
void blue(FILE *fp);
void coll(FILE *fp,char mem[P][10],int line,int type);
void coln(FILE *fp,char mem[P][10],int line,int type);
void date(FILE *fp,int kai,char mem[P][10],int line);
void err(char a);
void foot(FILE *fp);
void head(FILE *fp);
void red(FILE *fp);
void tomem(char buf[32],char mem[P][10],int line,int type);
void main(int argc,char *argv[]){
if(argc==4){
char buf[32],mem[P][10];
int i,line,type;
FILE *fp;
type=atoi(argv[2]);
if(type<3 || type>6) err(0);
line=atoi(argv[3]);
if(line<P) err(1);
if((fp=fopen(argv[1],"r"))==NULL) err(2);
i=0;
while(fgets(buf,31,fp)!=NULL){
if(i>=line-P && i<line) tomem(buf,mem,i-line+P,type);
i++; }
if(i<line) err(1);
fclose(fp);
fp=fopen("bmp.html","w");
head(fp);
i=P-1;
while(i>=0){
date(fp,line+i-P+1,mem,i);
if(type<5) coln(fp,mem,i,type);
else coll(fp,mem,i,type);
i--; }
foot(fp);
fclose(fp);
}
else printf("NUMBERS&LOTO BIT MAP\n");
}
void blue(FILE *fp){
fprintf(fp," bgcolor=\"#ccccff\"");
}
void coll(FILE *fp,char mem[P][10],int line,int type){
char i;
i=0;
while(i<=type+type*type){
fprintf(fp,"<td");
if(i==mem[line][3] || i==mem[line][4] || i==mem[line][5] || i==mem[line][6] || i==mem[line][7]) red(fp);
if(i==mem[line][8]){
if(type==5) blue(fp);
else red(fp); }
if(type==6 && i==mem[line][9]) blue(fp);
fprintf(fp,">%02d</td>",i+1); i++; }
}
void coln(FILE *fp,char mem[P][10],int line,int type){
char i;
i=0;
while(i<10*type){
fprintf(fp,"<td");
if(i%10==mem[line][3+i/10]) red(fp);
else if(i/10%2==1) blue(fp);
fprintf(fp,">%d</td>",i%10); i++; }
}
void date(FILE *fp,int kai,char mem[P][10],int line){
fprintf(fp,"<tr bgcolor=\"#ffffcc\"><td bgcolor=\"#cccccc\"");
if(line==P-1) fprintf(fp," width=\"13%%\"");
fprintf(fp,">#%d [%02d.%02d.%02d]</td>",kai,mem[line][0],mem[line][1],mem[line][2]);
}
void err(char a){
if(a==0) printf("TYPE ERROR\n");
else if(a==1) printf("LINE ERROR\n");
else if(a==1) printf("FILE OPEN ERROR\n");
exit(1);
}
void foot(FILE *fp){
fprintf(fp,"</table><p align=\"center\"><a href=\"../index.html\">INDEX</a><br><br>");
fprintf(fp,"Copyright nagirco. All rights reserved.</p></body></html>");
}
void head(FILE *fp){
fprintf(fp,"<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=shift_jis\">");
fprintf(fp,"<meta name=\"author\" content=\"nagirco\"><title>当せん番号一覧</title></head>");
fprintf(fp,"<body text=\"#000000\" bgcolor=\"#ffffff\"><h1>当せん番号一覧</h1>");
fprintf(fp,"<table align=\"center\" width=\"98%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">\n");
}
void red(FILE *fp){
fprintf(fp," bgcolor=\"#ffcccc\"");
}
void tomem(char buf[32],char mem[P][10],int line,int type){
char i;
i=2;
while(i<8){
mem[line][i/2-1]=10*(buf[i]-48)+buf[i+1]-48; i+=2; }
if(type==3){
i=9;
while(i<12){
mem[line][i-6]=buf[i]-48; i++; }
}
else if(type==4){
i=13;
while(i<17){
mem[line][i-10]=buf[i]-48; i++; }
}
else{
i=9;
while(i<12+3*type){
mem[line][i/3]=10*(buf[i]-48)+buf[i+1]-49; i+=3; }
}
}
#include <stdio.h>
#include <stdlib.h>
#define P 25
#define Q 43
void addbs(char buf[32],int base[2][Q],int type);
void blue(FILE *fp);
void bs2rnk(int base[2][Q],int rank[3][Q],int type);
void coll(FILE *fp,int rank[3][Q],char mem[P][10],int line,int type);
void coln(FILE *fp,int rank[3][Q],char mem[P][10],int line,int type);
void date(FILE *fp,int line1,char mem[P][10],int line2,int type);
void err(int a);
void foot(FILE *fp);
void head(FILE *fp);
void mm2rnk(char mem[P][10],int rank[3][Q],int line,int type);
void ordr(int a[3][Q],int b);
void red(FILE *fp);
void set0(int base[2][Q]);
void tomem(char buf[32],char mem[P][10],int line,int type);
void main(int argc,char *argv[]){
if(argc==4){
char buf[32],mem[P][10];
int base[2][Q],i,line,rank[3][Q],type;
FILE *fp;
type=atoi(argv[2]);
if(type<3 || type>6) err(0);
line=atoi(argv[3]);
if(line<P) err(2);
if((fp=fopen(argv[1],"r"))==NULL) err(1);
i=0;
while(i<10){
mem[P-1][i]=-1; i++; }
set0(base);
i=0;
while(fgets(buf,31,fp)!=NULL){
if(i<line-P) addbs(buf,base,type);
else if(i<line) tomem(buf,mem,i-line+P,type);
i++; }
if(i<line-1) err(2);
fclose(fp);
fp=fopen("frq.html","w");
head(fp);
i=P-1;
while(i>=0){
bs2rnk(base,rank,type);
mm2rnk(mem,rank,i,type);
ordr(rank,type);
date(fp,line+i-P+1,mem,i,type);
if(type<5) coln(fp,rank,mem,i,type);
else coll(fp,rank,mem,i,type);
fprintf(fp,"</tr>\n");
i--; }
foot(fp);
fclose(fp);
}
else printf("NUMBERS&LOTO FREQUENCY\n");
}
void addbs(char buf[32],int base[2][Q],int type){
int i,j;
if(type==3){
i=9;
while(i<12){
j=buf[i]-48; base[0][10*(i-9)+j]++; i++; }
}
else if(type==4){
i=13;
while(i<17){
j=buf[i]-48; base[0][10*(i-13)+j]++; i++; }
}
else{
i=9;
while(i<9+3*type){
j=10*(buf[i]-48)+buf[i+1]-49; base[0][j]++; i+=3; }
j=10*(buf[i]-48)+buf[i+1]-49; base[1][j]++;
}
}
void blue(FILE *fp){
fprintf(fp," bgcolor=\"#ccccff\"");
}
void bs2rnk(int base[2][Q],int rank[3][Q],int type){
int i;
if(type<5){
i=0;
while(i<10*type){
rank[0][i]=i%10; rank[1][i]=base[0][i]; i++; }
}
else{
i=0;
while(i<=type+type*type){
rank[0][i]=i; rank[1][i]=base[0][i]; rank[2][i]=base[1][i]; i++; }
}
}
void coll(FILE *fp,int rank[3][Q],char mem[P][10],int line,int type){
int i,j;
i=0;
while(i<3){
if(i>0) fprintf(fp,"</tr><tr align=\"right\">");
j=0;
while(j<=type+type*type){
fprintf(fp,"<td");
if(i==0){
if(rank[0][j]==mem[line][3] || rank[0][j]==mem[line][4] || rank[0][j]==mem[line][5] || rank[0][j]==mem[line][6] || rank[0][j]==mem[line][7]) red(fp);
if(rank[0][j]==mem[line][8]){
if(type==5) blue(fp);
else red(fp); }
if(type==6 && rank[0][j]==mem[line][9]) blue(fp); }
fprintf(fp,">");
if(i==0) fprintf(fp,"%02d",rank[0][j]+1);
else fprintf(fp,"%d",rank[i][j]);
fprintf(fp,"</td>"); j++; }
i++; }
}
void coln(FILE *fp,int rank[3][Q],char mem[P][10],int line,int type){
int i,j;
i=0;
while(i<2){
if(i>0) fprintf(fp,"</tr><tr align=\"right\">");
j=0;
while(j<10*type){
fprintf(fp,"<td");
if(i==0){
if(rank[0][j]==mem[line][j/10+3]) red(fp);
else if(j/10%2==1) blue(fp); }
fprintf(fp,">%d</td>",rank[i][j]); j++; }
i++; }
}
void date(FILE *fp,int line1,char mem[P][10],int line2,int type){
fprintf(fp,"<tr bgcolor=\"#ffffcc\"><td bgcolor=\"#cccccc\" rowspan=\"");
if(type<5) fprintf(fp,"2");
else fprintf(fp,"3");
fprintf(fp,"\"");
if(line2==P-1) fprintf(fp," width=\"8%%\"");
fprintf(fp,">#%d",line1);
if(mem[line2][0]>0) fprintf(fp,"<br>[%02d.%02d.%02d]",mem[line2][0],mem[line2][1],mem[line2][2]);
fprintf(fp,"</td>");
}
void err(int a){
if(a==0) printf("TYPE ERROR\n");
else if(a==1) printf("FILE OPEN ERROR\n");
else if(a==2) printf("LINE ERROR\n");
exit(1);
}
void foot(FILE *fp){
fprintf(fp,"</table><p align=\"center\"><a href=\"../index.html\">INDEX</a><br><br>");
fprintf(fp,"Copyright nagirco. All rights reserved.</p></body></html>");
}
void head(FILE *fp){
fprintf(fp,"<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=shift_jis\">");
fprintf(fp,"<meta name=\"author\" content=\"nagirco\"><title>出現回数一覧</title></head>");
fprintf(fp,"<body text=\"#000000\" bgcolor=\"#ffffff\"><h1>出現回数一覧</h1>");
fprintf(fp,"<table align=\"center\" width=\"98%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">\n");
}
void mm2rnk(char mem[P][10],int rank[3][Q],int line,int type){
int i,j,k;
if(type<5){
i=0;
while(i<line){
j=3;
while(j<3+type){
k=mem[i][j]; rank[1][10*(j-3)+k]++; j++; }
i++; }
}
else{
i=0;
while(i<line){
j=3;
while(j<3+type){
k=mem[i][j]; rank[1][k]++; j++; }
k=mem[i][j]; rank[2][k]++; i++; }
}
}
void ordr(int a[3][Q],int b){
int h,i,j,k;
if(b<5){
i=0;
while(i<10*b){
j=i;
while(j<i+9){
k=j+1;
while(k<i+10){
h=0;
if(a[1][j]<a[1][k]) h++;
else if(a[1][j]==a[1][k]){
if(a[0][j]>a[0][k]) h++; }
if(h>0){
h=a[0][j]; a[0][j]=a[0][k]; a[0][k]=h;
h=a[1][j]; a[1][j]=a[1][k]; a[1][k]=h; }
k++; }
j++; }
i+=10; }
}
else{
h=1+b+b*b;
i=0;
while(i<h-1){
j=i+1;
while(j<h){
k=0;
if(a[1][i]<a[1][j]) k++;
else if(a[1][i]==a[1][j]){
if(a[2][i]<a[2][j]) k++;
else if(a[2][i]==a[2][j]){
if(a[0][i]>a[0][j]) k++; }}
if(k>0){
k=a[0][i]; a[0][i]=a[0][j]; a[0][j]=k;
k=a[1][i]; a[1][i]=a[1][j]; a[1][j]=k;
k=a[2][i]; a[2][i]=a[2][j]; a[2][j]=k; }
j++; }
i++; }
}
}
void red(FILE *fp){
fprintf(fp," bgcolor=\"#ffcccc\"");
}
void set0(int base[2][Q]){
int i;
i=0;
while(i<Q){
base[0][i]=0; base[1][i]=0; i++; }
}
void tomem(char buf[32],char mem[P][10],int line,int type){
int i;
i=2;
while(i<8){
mem[line][i/2-1]=10*(buf[i]-48)+buf[i+1]-48; i+=2; }
if(type==3){
i=9;
while(i<12){
mem[line][i-6]=buf[i]-48; i++; }
}
else if(type==4){
i=13;
while(i<17){
mem[line][i-10]=buf[i]-48; i++; }
}
else{
i=9;
while(i<12+3*type){
mem[line][i/3]=10*(buf[i]-48)+buf[i+1]-49; i+=3; }
}
}
nclude <stdio.h>
#include <stdlib.h>
#define P 25
#define Q 43
void add1(int *a,int b);
void addbs(char buf[32],int base[2][Q],int type);
void blue(FILE *fp);
void bs2rnk(int base[2][Q],int rank[3][Q],int type);
void coll(FILE *fp,int rank[3][Q],char mem[P][10],int line,int type);
void coln(FILE *fp,int rank[3][Q],char mem[P][10],int line,int type);
void date(FILE *fp,int line1,char mem[P][10],int line2,int type);
void err(int a);
void foot(FILE *fp);
void head(FILE *fp);
void mm2rnk(char mem[P][10],int rank[3][Q],int line,int type);
void ordr(int a[3][Q],int b);
void red(FILE *fp);
void set0(int base[2][Q]);
void tomem(char buf[32],char mem[P][10],int line,int type);
void main(int argc,char *argv[]){
if(argc==4){
char buf[32],mem[P][10];
int base[2][Q],i,line,rank[3][Q],type;
FILE *fp;
type=atoi(argv[2]);
if(type<3 || type>6) err(0);
line=atoi(argv[3]);
if(line<P) err(2);
if((fp=fopen(argv[1],"r"))==NULL) err(1);
i=0;
while(i<10){
mem[P-1][i]=-1; i++; }
set0(base);
i=0;
while(fgets(buf,31,fp)!=NULL){
if(i<line-P) addbs(buf,base,type);
else if(i<line) tomem(buf,mem,i-line+P,type);
i++; }
if(i<line-1) err(2);
fclose(fp);
fp=fopen("spn.html","w");
head(fp);
i=P-1;
while(i>=0){
bs2rnk(base,rank,type);
mm2rnk(mem,rank,i,type);
ordr(rank,type);
date(fp,line+i-P+1,mem,i,type);
if(type<5) coln(fp,rank,mem,i,type);
else coll(fp,rank,mem,i,type);
fprintf(fp,"</tr>\n");
i--; }
foot(fp);
fclose(fp);
}
else printf("NUMBERS&LOTO SPAN\n");
}
void add1(int *a,int b){
char i;
i=0;
while(i<b){
*(a+i)+=1; i++; }
}
void addbs(char buf[32],int base[2][Q],int type){
int i,j;
if(type==3){
add1(base[0],30);
i=9;
while(i<12){
j=buf[i]-48; base[0][10*(i-9)+j]=0; i++; }
}
else if(type==4){
add1(base[0],40);
i=13;
while(i<17){
j=buf[i]-48; base[0][10*(i-13)+j]=0; i++; }
}
else{
add1(base[0],1+type+type*type); add1(base[1],1+type+type*type);
i=9;
while(i<9+3*type){
j=10*(buf[i]-48)+buf[i+1]-49; base[0][j]=0; i+=3; }
j=10*(buf[i]-48)+buf[i+1]-49; base[1][j]=0;
}
}
void blue(FILE *fp){
fprintf(fp," bgcolor=\"#ccccff\"");
}
void bs2rnk(int base[2][Q],int rank[3][Q],int type){
int i;
if(type<5){
i=0;
while(i<10*type){
rank[0][i]=i%10; rank[1][i]=base[0][i]; i++; }
}
else{
i=0;
while(i<=type+type*type){
rank[0][i]=i; rank[1][i]=base[0][i]; rank[2][i]=base[1][i]; i++; }
}
}
void coll(FILE *fp,int rank[3][Q],char mem[P][10],int line,int type){
int i,j;
i=0;
while(i<3){
if(i>0) fprintf(fp,"</tr><tr align=\"right\">");
j=0;
while(j<=type+type*type){
fprintf(fp,"<td");
if(i==0){
if(rank[0][j]==mem[line][3] || rank[0][j]==mem[line][4] || rank[0][j]==mem[line][5] || rank[0][j]==mem[line][6] || rank[0][j]==mem[line][7]) red(fp);
if(rank[0][j]==mem[line][8]){
if(type==5) blue(fp);
else red(fp); }
if(type==6 && rank[0][j]==mem[line][9]) blue(fp); }
fprintf(fp,">");
if(i==0) fprintf(fp,"%02d",rank[0][j]+1);
else fprintf(fp,"%d",rank[i][j]);
fprintf(fp,"</td>"); j++; }
i++; }
}
void coln(FILE *fp,int rank[3][Q],char mem[P][10],int line,int type){
int i,j;
i=0;
while(i<2){
if(i>0) fprintf(fp,"</tr><tr align=\"right\">");
j=0;
while(j<10*type){
fprintf(fp,"<td");
if(i==0){
if(rank[0][j]==mem[line][j/10+3]) red(fp);
else if(j/10%2==1) blue(fp); }
fprintf(fp,">%d</td>",rank[i][j]); j++; }
i++; }
}
void date(FILE *fp,int line1,char mem[P][10],int line2,int type){
fprintf(fp,"<tr bgcolor=\"#ffffcc\"><td bgcolor=\"#cccccc\" rowspan=\"");
if(type<5) fprintf(fp,"2");
else fprintf(fp,"3");
fprintf(fp,"\"");
if(line2==P-1) fprintf(fp," width=\"8%%\"");
fprintf(fp,">#%d",line1);
if(mem[line2][0]>0) fprintf(fp,"<br>[%02d.%02d.%02d]",mem[line2][0],mem[line2][1],mem[line2][2]);
fprintf(fp,"</td>");
}
void err(int a){
if(a==0) printf("TYPE ERROR\n");
else if(a==1) printf("FILE OPEN ERROR\n");
else if(a==2) printf("LINE ERROR\n");
exit(1);
}
void foot(FILE *fp){
fprintf(fp,"</table><p align=\"center\"><a href=\"../index.html\">INDEX</a><br><br>");
fprintf(fp,"Copyright nagirco. All rights reserved.</p></body></html>");
}
void head(FILE *fp){
fprintf(fp,"<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=shift_jis\">");
fprintf(fp,"<meta name=\"author\" content=\"nagirco\"><title>出現間隔一覧</title></head>");
fprintf(fp,"<body text=\"#000000\" bgcolor=\"#ffffff\"><h1>出現間隔一覧</h1>");
fprintf(fp,"<table align=\"center\" width=\"98%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">\n");
}
void mm2rnk(char mem[P][10],int rank[3][Q],int line,int type){
int i,j,k;
if(type<5){
i=0;
while(i<line){
add1(rank[1],10*type);
j=3;
while(j<3+type){
k=mem[i][j]; rank[1][10*(j-3)+k]=0; j++; }
i++; }
}
else{
i=0;
while(i<line){
add1(rank[1],1+type+type*type); add1(rank[2],1+type+type*type);
j=3;
while(j<3+type){
k=mem[i][j]; rank[1][k]=0; j++; }
k=mem[i][j]; rank[2][k]=0; i++; }
}
}
void ordr(int a[3][Q],int b){
int h,i,j,k;
if(b<5){
i=0;
while(i<10*b){
j=i;
while(j<i+9){
k=j+1;
while(k<i+10){
h=0;
if(a[1][j]>a[1][k]) h++;
else if(a[1][j]==a[1][k]){
if(a[0][j]>a[0][k]) h++; }
if(h>0){
h=a[0][j]; a[0][j]=a[0][k]; a[0][k]=h;
h=a[1][j]; a[1][j]=a[1][k]; a[1][k]=h; }
k++; }
j++; }
i+=10; }
}
else{
h=1+b+b*b;
i=0;
while(i<h-1){
j=i+1;
while(j<h){
k=0;
if(a[1][i]>a[1][j]) k++;
else if(a[1][i]==a[1][j]){
if(a[2][i]>a[2][j]) k++;
else if(a[2][i]==a[2][j]){
if(a[0][i]>a[0][j]) k++; }}
if(k>0){
k=a[0][i]; a[0][i]=a[0][j]; a[0][j]=k;
k=a[1][i]; a[1][i]=a[1][j]; a[1][j]=k;
k=a[2][i]; a[2][i]=a[2][j]; a[2][j]=k; }
j++; }
i++; }
}
}
void red(FILE *fp){
fprintf(fp," bgcolor=\"#ffcccc\"");
}
void set0(int base[2][Q]){
int i;
i=0;
while(i<Q){
base[0][i]=0; base[1][i]=0; i++; }
}
void tomem(char buf[32],char mem[P][10],int line,int type){
int i;
i=2;
while(i<8){
mem[line][i/2-1]=10*(buf[i]-48)+buf[i+1]-48; i+=2; }
if(type==3){
i=9;
while(i<12){
mem[line][i-6]=buf[i]-48; i++; }
}
else if(type==4){
i=13;
while(i<17){
mem[line][i-10]=buf[i]-48; i++; }
}
else{
i=9;
while(i<12+3*type){
mem[line][i/3]=10*(buf[i]-48)+buf[i+1]-49; i+=3; }
}
}