アットウィキロゴ

失敗

class pro{

String str;
String[] ph=new String[100];
String[] word=new String[100];
int[] nword=new int[100];
String[] dic=new String[100];
int[] np=new int[100];
double[] p=new double[100];
int s,sx,phnumber,dicnumber,wordnumber;

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

pro(){

p[0]=1;

str="朝は朝です";

makeword(str);

makedic();





}

void makep(){
int h,i;

for(s=1;s<wordnumber+1;s++){
h=0;
if(np[s]==0)h=100;
i=0;
while(h>50){
for(sx=1;sx<dicnumber+1;sx++){
if(word[s].equals(dic[sx]))h=0;
}
if(h>70)h=30;
}
if(h>20)dicnumber=dicnumber+1;
if(h>20)dic[dicnumber]=word[s];
}

}

void makedic(){
int h,i;

for(s=1;s<wordnumber+1;s++){
h=0;
if(np[s]==0)h=100;
i=0;
while(h>50){
for(sx=1;sx<dicnumber+1;sx++){
if(word[s].equals(dic[sx]))h=0;
}
if(h>70)h=30;
}
if(h>20)dicnumber=dicnumber+1;
if(h>20)dic[dicnumber]=word[s];
}

}
void makeword(String str){
int n1;
double p1,maxp;
maxp=-999;
for(n1=1;n1<11;n1++){
makeph(str);
makenp();
p1=point();
if(p1>maxp)word=ph;
if(p1>maxp)nword=np;
if(p1>maxp)wordnumber=phnumber;
if(p1>maxp)maxp=p1;
}

}
double point(){
double pt;
sx=np[1];
pt=p[sx];
for(s=2;s<phnumber+1;s++){
sx=np[s];
pt=pt*p[sx];
}
return pt;
}

void makenp(){

for(s=1;s<phnumber+1;s++){
np[s]=0;
for(sx=1;sx<dicnumber+1;sx++){
if(ph[s].equals(dic[sx]))np[s]=sx;
}
}

}
void makeph(String str){
int[] z=new int[100];
int[] zz=new int[100];
int zlong;

zlong=str.length();
z[0]=1;
for(s=1;s<zlong;s++){
z[s]=0;
if(Math.random()>0.5)z[s]=1;
}

sx=1;
zz[1]=0;
for(s=1;s<zlong;s++){
if(z[s]==1)sx=sx+1;
if(z[s]==1)zz[sx]=s;
}

phnumber=sx;
for(s=1;s<phnumber;s++){
ph[s]=str.substring(zz[s],zz[s+1]);
}
s=phnumber;
ph[s]=str.substring(zz[s],zlong);
}
}
最終更新:2011年05月23日 03:54