アットウィキロゴ

dfcvb

class pro{

String str;
String[] dic=new String[100];
double[] p=new double[100];  
double[] v=new double[100];
int[] gototx=new int[100];

int strlong;
String ph;
int dicnumber;
int sx;
int t,tx,txs;
double p1,v1,maxv;

public static void main(String args[]){
pro test=new pro();
}

pro(){

p[0]=0.01;
dicnumber=0;

str="どんぶりは犬の餌です";
strlong=str.length();
ph=str.substring(0,1);

p1=p[0];
for(sx=1;sx<dicnumber+1;sx++){
if(ph.equals(dic[sx]))p1=p[sx];
}
v[0]=p1;

for(t=1;t<strlong;t++){
ph=str.substring(0,t+1);
p1=p[0];
for(sx=1;sx<dicnumber+1;sx++){
if(ph.equals(dic[sx]))p1=p[sx];
}
txs=0;
maxv=p1;
for(tx=0;tx<t;tx++){
ph=str.substring(tx+1,t+1);
p1=p[0];
for(sx=1;sx<dicnumber+1;sx++){
if(ph.equals(dic[sx]))p1=p[sx];
}
v1=p1+v[tx];
if(v1>maxv)txs=tx;
if(v1>maxv)maxv=v1;
}
gototx[t]=txs;
v[t]=maxv;
}


t=strlong-1;
while(t>0){
tx=gototx[t];
ph=str.substring(tx+1,t+1);
t=tx;
System.out.println(ph);
}
ph=str.substring(0,t+1);
System.out.println(ph);


}
}
最終更新:2011年05月27日 06:06