アットウィキロゴ

gamegameaozao

import java.io.*;

class game{
int[] rank=new int[3000];
String[] data=new String[50000];
String[] pos=new String[10000];
String[] reading=new String[10000];
String[] surface=new String[10000];
String[] dic=new String[10000];
int[] dnumber=new int[10000];
int datanumber,dicnumber;
String a1,a2,a3,a4,a5;
int m,n,s,sx;

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

game(){

makefile();

System.out.println(datanumber);

for(s=1;s<datanumber+1;s++){
makedata(data[s]);  
n=Integer.parseInt(a1);
surface[n]=a2;
reading[n]=a3;
pos[n]=a4;
}

makedic();

System.out.println(dicnumber);

catchdic();

ranking();

for(s=1;s<100;s++){
sx=rank[s];
System.out.print(dic[sx]);
System.out.print(",");
System.out.println(dnumber[sx]);

}



}

void ranking(){
int sxs,maxd,maxp,nx,h;
int p;
sxs=0;
maxd=-999;
for(sx=1;sx<dicnumber+1;sx++){
if(dnumber[sx]>maxd)sxs=sx;
if(dnumber[sx]>maxd)maxd=dnumber[sx];
}
rank[1]=sxs;
nx=1;
for(sx=1;sx<dicnumber+1;sx++){
h=0;
if(dnumber[sx]==maxd)h=100;
if(sx==sxs)h=0;
if(h>50)nx=nx+1;
if(h>50)rank[nx]=sx;
}

maxp=maxd;
while(maxp>2){
sxs=0;
maxd=-999;
for(sx=1;sx<dicnumber+1;sx++){
h=0;
if(dnumber[sx]>maxd)h=100;
if(dnumber[sx]<maxp)h=h+100;
if(h>150)sxs=sx;
if(h>150)maxd=dnumber[sx];
}
nx=nx+1;
rank[nx]=sxs;
for(sx=1;sx<dicnumber+1;sx++){
h=0;
if(dnumber[sx]==maxd)h=100;
if(sx==sxs)h=0;
if(h>50)nx=nx+1;
if(h>50)rank[nx]=sx;
}
maxp=maxd;

}



}
void catchdic(){

for(sx=1;sx<dicnumber+1;sx++){
dnumber[sx]=0;
}


for(s=1;s<datanumber+1;s++){
for(sx=1;sx<dicnumber+1;sx++){
if(surface[s].equals(dic[sx]))dnumber[sx]=dnumber[sx]+1;
}
}


}
void makedic(){
int h;

dicnumber=1;
dic[1]=surface[1];
for(s=2;s<datanumber+1;s++){
h=0;
for(sx=1;sx<dicnumber+1;sx++){
if(surface[s].equals(dic[sx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=surface[s];
}


}
void makedata(String str){
int p1,p2,p3,p4,p5,p6,p7,p8;
p1=str.indexOf("<");
p2=str.indexOf(">",p1);
p3=str.indexOf("<",p2);
p4=str.indexOf(">",p3);
p5=str.indexOf("<",p4);
p6=str.indexOf(">",p5);
p7=str.indexOf("<",p6);
p8=str.indexOf(">",p7);
if(p2>p1)a1=str.substring(p1+1,p2);
if(p4>p3)a2=str.substring(p3+1,p4);
if(p6>p5)a3=str.substring(p5+1,p6);
if(p8>p7)a4=str.substring(p7+1,p8);
}

void makefile(){

String str;

s=0;
try{
BufferedReader br =new BufferedReader(new FileReader("ren.txt"));
while((str = br.readLine()) != null) {        
s=s+1;
data[s]=str;
}
br.close();
}
catch(IOException e){ System.out.println("入出力エラーです。");}
datanumber=s;
}

}
最終更新:2011年04月21日 19:40