アットウィキロゴ

buse888

package busekei;
 
import java.io.*;
 
 
public class pro {
 
    int s,datanumber;
    String[] data=new String[500000];
   String[] subdate=new String[5000];
     String[] date=new String[500000];
        String[] code=new String[500000];
      String[] name=new String[500000];
        int number;
    String[] id=new String[5000];
    int[] point=new int[500000];
  int[] v=new int[5000];
  int[] vs=new int[5000];
           int dicnumber=0;
 String[] dic=new String[5000]; 
  int[] p=new int[5000];
  int[] rank=new int[5000];
  int delta=0;
 
 String[] dic_code=new String[5000];
 String[] dic_name=new String[5000];
 
    public static void main(String[] args) {
       pro te=new pro();
    }
 
    pro(){
 
 
 
   readx("500.csv");
 
 
  for(s=2;s<datanumber+1;s++){
 
String[] x=data[s].split(",");
    date[s-1]=x[0]+"年"+x[1]+"月"+x[2]+"日";
    point[s-1]=numx(x[6]);
 code[s-1]="";
 name[s-1]=x[5];
  if(x.length>9)code[s-1]=x[9];
        }
 
 number=datanumber-1;
 int sx;
 
 dic_code[0]="";
 for(s=1;s<number+1;s++){
     int h=0;
 for(sx=0;sx<delta+1;sx++){
 if(code[s].equals(dic_code[sx]))h=100;
 }    
 if(h<60)delta=delta+1;
 if(h<60)dic_code[delta]=code[s];
  if(h<60)dic_name[delta]=name[s];
 }
 
 System.out.println(delta);
 
 for(s=1;s<number+1;s++){
     int sxs=0;
 for(sx=0;sx<delta+1;sx++){
 if(code[s].equals(dic_code[sx]))sxs=sx;
 }    
 p[sxs]=p[sxs]+point[s];
 }
 
 
 ranking();
 
 sx=rank[20];
 String str=dic_code[sx];
System.out.println(dic_name[sx]); 
 
 sx=0;
 for(s=1;s<number+1;s++){
 if(code[s].equals(str))sx=sx+1;
 if(code[s].equals(str))subdate[sx]=date[s];
 if(code[s].equals(str))v[sx]=point[s];
 }
 
 number=sx;
 
 
 int dicnumber=0;
  for(s=1;s<number+1;s++){
   int h=0;   
  for(sx=1;sx<dicnumber+1;sx++){
  if(subdate[s].equals(dic[sx]))h=100;
  }
  if(h<50)dicnumber=dicnumber+1;
   if(h<50)dic[dicnumber]=subdate[s];
  }
 
   System.out.println(dicnumber);
 
   for(s=1;s<dicnumber+1;s++){
   vs[s]=0;    
   }
 
  for(s=1;s<number+1;s++){   
  for(sx=1;sx<dicnumber+1;sx++){
  if(subdate[s].equals(dic[sx]))vs[sx]=vs[sx]+v[s];
  }
  }
 
 
 for(s=1;s<dicnumber+1;s++){
 System.out.println(dic[s]+","+vs[s]);    
 }
 
 
 
 
 
 
    }
 
     void ranking(){ 
int r,s,sx,h; 
int[] ch=new int[2001];
double maxu;
 
for(r=1;r<delta+1;r++){ 
sx=0; 
maxu=-999999; 
for(s=1;s<delta+1;s++){ 
h=0; 
if(p[s]>maxu)h=h+1; 
if(ch[s]<50)h=h+1; 
if(h==2)maxu=p[s]; 
if(h==2)sx=s; 
}
rank[r]=sx; 
ch[sx]=100; 
}
 
 
}
 
 
 
     void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=1;s<dicnumber+1;s++){  
pw.print(dic[s]); 
pw.print(","); 
pw.println(v[s]); 
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
    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;
 
} 
 
 
       int numx(String str){
 
    int nx;
 
    nx=0;
 
 try{
 
    nx=Integer.parseInt(str);
 
 }catch (Exception e) {}
 
 return nx;
 
 
 
}
 
}
最終更新:2016年08月13日 02:17