アットウィキロゴ

lp06 06

public class lp07{
public static void main(String[] args) {
double x[][]=new double[10][14];
double c1,x1,u1,uc1,ux1,uc2,ux2;
double h;
int m,n,p;
int maxn,maxm;
double maxv,minv;
double x2,z,cs1,xs1,cs2,xs2;
double th;
int t1,t2;
th=1.1;
h=0.01;
cs1=0.6;
xs1=0.4;
cs2=0.4;
xs2=0.6;
t2=0;
while(t2<100){
uc1=1/cs1;
ux1=1/xs1;
uc2=1/cs2;
ux2=1/xs2;
for (m=0;m<10;m++){
for (n=0;n<14;n++){
x[m][n]=0;
}
}

x[0][1]=uc1;
x[0][2]=ux1;
x[0][3]=uc2;
x[0][4]=ux2;

x[1][1]=1;
x[1][5]=1;
x[1][0]=cs1+h;

x[2][1]=-1;
x[2][6]=1;
x[2][0]=-cs1+h;

x[3][2]=1;
x[3][7]=1;
x[3][0]=xs1+h;

x[4][2]=-1;
x[4][8]=1;
x[4][0]=-xs1+h;

x[5][3]=1;
x[5][9]=1;
x[5][0]=cs2+h;

x[6][3]=-1;
x[6][10]=1;
x[6][0]=-cs2+h;

x[7][4]=1;
x[7][11]=1;
x[7][0]=xs2+h;

x[8][4]=-1;
x[8][12]=1;
x[8][0]=-xs2+h;

x[9][1]=1;
x[9][2]=1;
x[9][3]=1;
x[9][4]=1;
x[9][13]=1;
x[9][0]=2;

maxv=0;
maxn=0;
for (n=1;n<14;n++){
if (x[0][n]>maxv)maxn=n;
if (x[0][n]>maxv)maxv=x[0][n];
}

t1=0;
while(t1<100){

minv=900;
maxm=0;
for (m=1;m<10;m++){
x1=x[m][maxn];
p=0;
if (x1==0)p=100;
if (p>50)x1=1;
x2=x[m][0]/x1;
if (p>50)x2=1000;
if (x2<0)x2=1000;
if (x2<minv)maxm=m;
if (x2<minv)minv=x2;
}

for (m=0;m<10;m++){
z=x[m][maxn]/x[maxm][maxn];
if (m==maxm)z=0;
for (n=0;n<14;n++){
x[m][n]=x[m][n]-z*x[maxm][n];
}
}

maxv=0;
maxn=0;
for (n=1;n<14;n++){
if (x[0][n]>maxv)maxn=n;
if (x[0][n]>maxv)maxv=x[0][n];
}
if (maxv==0)t1=1000;
t1=t1+1;
}

z=0;
for (m=1;m<10;m++){
if (x[m][1]>0)z=x[m][0]/x[m][1];
if (x[m][1]<0)z=x[m][0]/x[m][1];
}
cs1=z;  

z=0;
for (m=1;m<10;m++){
if (x[m][2]>0)z=x[m][0]/x[m][2];
if (x[m][2]<0)z=x[m][0]/x[m][2];
}
xs1=z;  

z=0;
for (m=1;m<10;m++){
if (x[m][3]>0)z=x[m][0]/x[m][3];
if (x[m][3]<0)z=x[m][0]/x[m][3];
}
cs2=z;  

z=0;
for (m=1;m<10;m++){
if (x[m][4]>0)z=x[m][0]/x[m][4];
if (x[m][4]<0)z=x[m][0]/x[m][4];
}
xs2=z;  
t2=t2+1;
}

System.out.println(cs1);
System.out.println(xs1);
System.out.println(cs2);
System.out.println(xs2);
}
}
最終更新:2010年06月10日 05:47