package rank3;
import tool.readfile;
import java.io.*;
public class pro {
int s,datanumber;
String[] data=new String[500000];
String[] dic=new String[50000];
String[] dic_code=new String[50000];
String[] artist=new String[500000];
String[] code=new String[500000];
int number;
int[] point=new int[50000];
int[] v=new int[50000];
int dicnumber=0;
int[] rank=new int[50000];
public static void main(String[] args) {
pro u=new pro();
}
pro(){
readx("p4.csv");
for(s=1;s<datanumber+1;s++){
String[] x=data[s].split(",");
artist[s]="";
if(x.length==4) artist[s]=x[2];
if(x.length==4) code[s]=x[3];
}
int sx;
for(s=1;s<datanumber+1;s++){
int h=0;
for(sx=1;sx<dicnumber+1;sx++){
if(artist[s].equals(dic[sx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=artist[s];
if(h<50)dic_code[dicnumber]=code[s];
}
System.out.println(dic[1]);
for(s=1;s<datanumber+1;s++){
for(sx=1;sx<dicnumber+1;sx++){
if(artist[s].equals(dic[sx]))point[sx]=point[sx]+1;
}
}
ranking();
for(s=1;s<3001;s++){
sx=rank[s];
System.out.println(dic[sx]+","+dic_code[sx]+","+point[sx]);
}
}
void readx(String file){
String str;
BufferedReader br;
int s;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));
while((str = br.readLine()) != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
datanumber=s;
}
void ranking(){
int r,s,sx,h;
int[] ch=new int[80000];
double maxu;
for (r = 1; r < 3001; r++) {
sx = 0;
maxu = -999999;
for (s = 1; s < dicnumber + 1; s++) {
h = 0;
if (point[s] > maxu) h = h + 1;
if (ch[s] < 50) h = h + 1;
if (h == 2) maxu =point[s];
if (h == 2) sx = s;
}
rank[r] = sx;
ch[sx] = 100;
}
}
int num_int(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
}
最終更新:2017年07月08日 15:14