アットウィキロゴ

ce00582UUU

import java.io.*;

class ren{

int s,sx,sxs,datanumber;
String[] data=new String[50000];  
String[] article=new String[50000];
String[] dic=new String[50000];  
String[] author=new String[50000];
int[] nat=new int[50000];
int[] num=new int[50000];
int[] ch=new int[50000];
int[] rank=new int[50000];
int articlenumber,dicnumber;
int p1,p2,h,r;
String str,str1,str2;
int maxn;

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

ren(){

readfile("article.txt");

articlenumber=datanumber;

for(s=1;s<articlenumber;s++){
String[] x=data[s].split(",");
article[s]=x[1];
}

str1="(";
str2=")";

for(s=1;s<articlenumber;s++){
author[s]="";
h=0;
p1=article[s].indexOf(str1);
p2=article[s].indexOf(str2);
if(p1>-1)h=h+1;
if(p2>p1+1)h=h+1;
if(h==2)author[s]=article[s].substring(p1+1,p2);
}

dicnumber=0;

for (s=1;s<articlenumber+1;s++){
sxs=0;
str=author[s];
if(str==null)str="AAAAAA";
for(sx=1;sx<dicnumber+1;sx++){
if(str.equals(dic[sx]))sxs=sx;
}
if(sxs<1)dicnumber=dicnumber+1;
if(sxs<1)dic[dicnumber]=author[s];
if(sxs<1)nat[s]=dicnumber;
if(sxs>0)nat[s]=sxs;
}


for(s=1;s<articlenumber+1;s++){
sx=nat[s];
num[sx]=num[sx]+1;
}

for(r=1;r<1001;r++){
maxn=0;
sx=0;
for(s=1;s<dicnumber+1;s++){
h=0;
if(num[s]>maxn)h=h+1;
if(ch[s]<50)h=h+1;
if(h==2)maxn=num[s];
if(h==2)sx=s;
}
ch[sx]=100;
rank[r]=sx;
}

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

writefile("author.txt");


}

void writefile(String str){

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

for(s=1;s<1001;s++){        
pw.print(s);      
pw.print(",");    
sx=rank[s];
pw.println(dic[sx]);              
}      

System.out.println("ファイルに書きこみました。");

pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }

}






void readfile(String file){

String str;
BufferedReader br;
int s;
s=0;

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

}



}
最終更新:2011年06月08日 22:07