アットウィキロゴ

2xg

import java.io.*;

class game{

String[] data=new String[10000];
String file,str;
int page,s,sx,datanumber;
int y,m,d,n;
int[][][] num=new int[20][13][32];
int[][][] c=new int[49][20][13];
int[] rank=new int[49];
String[] artist=new String[49];

int p1,p2,c1;

public static void main(String [] args) {
       game test=new game(); 
           } 

game(){


for (page=1;page<49;page++){

file="data/";
file=file+page;
file=file+".txt";

readfile(file);

str=data[1];
p1=str.indexOf("<artist>");
p2=str.indexOf("</artist>");
str=str.substring(p1,p2);
artist[page]=str.replace("<artist>","");

for(s=1;s<datanumber+1;s++){
str=data[s];
p1=str.indexOf("<year>");
p2=str.indexOf("</year>");
str=str.substring(p1,p2);
str=str.replace("<year>","");
y=Integer.parseInt(str);
str=data[s];
p1=str.indexOf("<month>");
p2=str.indexOf("</month>");
str=str.substring(p1,p2);
str=str.replace("<month>","");
m=Integer.parseInt(str);
str=data[s];
p1=str.indexOf("<day>");
p2=str.indexOf("</day>");
str=str.substring(p1,p2);
str=str.replace("<day>","");
d=Integer.parseInt(str);
str=data[s];
p1=str.indexOf("<num>");
p2=str.indexOf("</num>");
str=str.substring(p1,p2);
str=str.replace("<num>","");
num[y][m][d]=Integer.parseInt(str);
}

for(y=8;y<12;y++){
for(m=1;m<13;m++){
c1=0;
for(d=1;d<32;d++){
c1=c1+num[y][m][d];
}
c[page][y][m]=c1;
}
}


}

for(y=11;y<12;y++){
for(m=1;m<8;m++){

ranking(y,m);

System.out.println(m);

for(s=1;s<11;s++){
sx=rank[s];
System.out.println(artist[sx]);
}

}
}



}

void ranking(int y,int m){
int r,s,sx,maxc,h;
int[] ch=new int[49];

for(r=1;r<49;r++){
sx=0;
maxc=-999;
for(s=1;s<49;s++){
h=0;
if(c[s][y][m]>maxc)h=h+1;
if(ch[s]<50)h=h+1;
if(h==2)maxc=c[s][y][m];
if(h==2)sx=s;
}
rank[r]=sx;
ch[sx]=100;
}


}

void writefile(String file){

try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(file)));

pw.println(s);

System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }

}




void readfile(String file){
int s;
String str;
BufferedReader br;

s=0;

try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));
while*1 != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}


datanumber=s;

}



}
最終更新:2011年08月06日 02:51