package movie;
import java.io.*;
public class pro {
int s,datanumber;
String[] data=new String[300000];
String[] code=new String[50000];
String[] dic=new String[50000];
int[] point=new int[50000];
String[] title=new String[500000];
int[] sale=new int[500000];
int[] seat=new int[500000];
int[] year=new int[500000];
int[] month=new int[500000];
int[] day=new int[500000];
int[] ths=new int[500000];
String[] time=new String[500000];
String[] th=new String[500000];
int[] rank=new int[7000];
int dicnumber=0;
public static void main(String[] args) {
pro t=new pro();
}
pro(){
readx("data.csv");
for(s=2;s<datanumber+1;s++){
String[] x=data[s].split(",");
year[s-1]=numx(x[0]);
month[s-1]=numx(x[1]);
day[s-1]=numx(x[2]);
time[s-1]=x[3];
th[s-1]=x[4];
title[s-1]=x[5];
sale[s-1]=numx(x[6]);
seat[s-1]=numx(x[7]);
ths[s-1]=numx(x[8]);
}
int sx;
for(s=1;s<datanumber;s++){
int h=0;
for(sx=1;sx<dicnumber+1;sx++){
if(title[s].equals(dic[sx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=title[s];
}
System.out.println(dicnumber);
for(s=1;s<datanumber;s++){
int sxs=0;
for(sx=1;sx<dicnumber+1;sx++){
if(title[s].equals(dic[sx]))sxs=sx;
}
point[sxs]=point[sxs]+sale[s];
}
ranking();
for(s=1;s<101;s++){
sx=rank[s];
System.out.println(dic[sx]+","+point[sx]);
}
}
void ranking(){
int r,s,sx,h;
int[] ch=new int[7000];
double maxu;
for (r = 1; r < dicnumber + 1; 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 numx(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
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;
}
}
最終更新:2016年07月08日 16:16