アットウィキロゴ

p081902

package memo;
 
 
public class pro {
 
 
    int sx,number;
int[] month=new int[500];
int[] year=new int[500];
String[] v=new String[500];
int[] y=new int[500];
 
 
    int[] rank=new int[500];
 
public static void main(String[] args) {
        pro t=new pro();
    }
    pro(){
 
        String db,tab;
 
 
        db="jyu";
        tab="jyu";
 
        select sub=new select();
        sub.makedata(db,tab,"p27","c2");
        number=sub.number;
        v=sub.v;
        year=sub.year;
        month=sub.month;
 
 
    int s;
 
      for(s=1;s<number+1;s++){   
      y[s]=100*year[s]+month[s];
      }
 
      ranking();
 
    for(s=1;s<number+1;s++){   
    sx=rank[number-s+1];
    System.out.println(year[sx]+"年"+month[sx]+"月,"+v[sx]);     
    }
 
 
 
 
 
 
    }
 
 
 
     void ranking(){ 
int r,s,sx,h; 
int[] ch=new int[2001];
double maxu;
 
for(r=1;r<number+1;r++){ 
sx=0; 
maxu=-999999; 
for(s=1;s<number+1;s++){ 
h=0; 
if(y[s]>maxu)h=h+1; 
if(ch[s]<50)h=h+1; 
if(h==2)maxu=y[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[50000];
String[] v=new String[50000];
String[] v2=new String[50000];
int[] month=new int[50000];
 
void makedata(String db,String tab,String p1,String c1){ 
 
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 pref = "+change(p1)+" and credit="+change(c1);   
rsx = stx.executeQuery(sqx); 
if (rsx != null) { 
while (rsx.next()) { 
sx=sx+1;
v[sx]= rsx.getString("value");
year[sx]=rsx.getInt("year");
month[sx]=rsx.getInt("month");
} 
} 
 
number=sx;
 
 
rsx.close(); 
stx.close(); 
dbx.close(); 
 
} catch (Exception ex) {ex.printStackTrace();} 
 
 
 
 
} 
 
String change(String word){
String e;
e="'"+word+"'";
return e;    
}    
 
 
 
}
 
最終更新:2015年08月26日 02:08