package memo;
import tool.*;
public class pro {
int sx,number;
int[] year=new int[5000];
String[] ex=new String[5000];
int[] month=new int[5000];
double[] delta=new double[500];
String[] com=new String[5000];
int[] rank=new int[2001];
String[] data=new String[50000];
String[] bus=new String[500];
String[] code=new String[500];
int s,datanumber;
public static void main(String[] args) {
pro t=new pro();
}
pro(){
readfile sub=new readfile();
sub.makedata("code.txt","UTF-8");
data=sub.data;
datanumber=sub.datanumber;
for(s=1;s<datanumber+1;s++){
String[] x=data[s].split(",");
com[s]=x[1];
code[s]=x[0];
}
String db,tab;
db="line";
tab="t2";
int s;
select sub2=new select();
sub2.makedata(db,tab,"cr7");
number=sub2.number;
ex=sub2.v;
bus=sub2.com;
for(s=1;s<number+1;s++){
delta[s]=num(ex[s]);
}
ranking();
for(s=1;s<11;s++){
String cc="";
int n=rank[s];
for(sx=1;sx<datanumber+1;sx++){
if(bus[n].equals(code[sx]))cc=com[sx];
}
System.out.println(cc+","+(int)(delta[n]/100000));
}
}
void ranking(){
int r,s,sx,h;
int[] ch=new int[2001];
double maxu;
int t;
for(r=1;r<11;r++){
sx=0;
maxu=-999;
for(s=1;s<number+1;s++){
h=0;
if(delta[s]>maxu)h=h+1;
if(ch[s]<50)h=h+1;
if(h==2)maxu=delta[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;
}
double num(String str){
double nx;
nx=0;
try{
nx=Double.parseDouble(str);
}catch (Exception e) {}
return nx;
}
}
package memo;
import java.sql.*;
class select{
Connection dbx;
Statement stx;
String sqx;
ResultSet rsx;
int key;
String word;
int sx,number;
int[] year=new int[5000];
String[] v=new String[5000];
String[] com=new String[5000];
int[] month=new int[5000];
int[] day=new int[500];
void makedata(String db,String tab,String cr1){
String url = "jdbc:h2:"+db+";create=true";
String usr = "";
String pwd = "";
try
{
Class.forName("org.h2.Driver");
dbx = DriverManager.getConnection(url, usr, pwd);
} catch (Exception ex) { ex.printStackTrace();}
sx=0;
try {
stx = dbx.createStatement();
sqx="select * from "+tab+" WHERE credit="+change(cr1);
rsx = stx.executeQuery(sqx);
if (rsx != null) {
while (rsx.next()) {
sx=sx+1;
v[sx]= rsx.getString("value");
com[sx]=rsx.getString("com");
}
}
number=sx;
rsx.close();
stx.close();
dbx.close();
} catch (Exception ex) {ex.printStackTrace();}
}
String change(String word){
String e;
e="'"+word+"'";
return e;
}
}
最終更新:2015年09月03日 09:07