Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  a.java
Language: JAVA
Code:
public class v57brPf9 {

    public static void main(String[] args) {
        String pro[][]=new String[4][4];
String pro1[][]=new String[4][4];
int i,k=1,a=1,j,b=0,b1=0,u=0,b2=0,c,c1,c2,m=3,s,t,v,w,x,y;
int e=0,f=0,g=0,g1=0,n,n1,n2,n3,h,h1,l,l1;
String T[]=new String[8];
String TT[][]=new String[8][8];
String TTp[][]=new String[8][8];
String id[][]=new String[8][8];
String TTs[][]=new String[8][8];
String TT1[][]=new String[8][8];
String TT1p[][]=new String[8][8];
String TT1s[][]=new String[8][8];
String TTe[][]=new String[8][8];
String TTless[][]=new String[8][8];
String TTgre[][]=new String[8][8];
String TTgre1[][]=new String[8][8];
String TTspm[][]=new String[8][8];

pro[0][0]="Z";
pro[0][1]="b";
pro[0][2]="M";
pro[0][3]="b";

pro[1][0]="M";
pro[1][1]="a";
pro[1][2]="";
pro[1][3]="";

pro[2][0]="L";
pro[2][1]="M";
pro[2][2]="a";
pro[2][3]=")";

pro[3][0]="M";
pro[3][1]="(";
pro[3][2]="L";
pro[3][3]="";

T[1]="Z";
T[2]="b";
T[3]="M";
T[4]="L";
T[5]="a";
T[6]="(";
T[7]=")";

System.out.println("Productions are:");
for(i=0;i<4;i++)
{

System.out.println(pro[i][0]+"---->"+pro[i][1]+pro[i][2]+pro[i][3]);
}
TT[0][0]=(" ");
for(k=1;k<8;k++)
{
     TT[k][0]=T[k];
     TT[0][k]=T[k];
}
for(i=0;i<4;i++)
{
     for(j=0;j<8;j++)
     {
          if(pro[i][0]==TT[j][0])
          {
               for(u=0;u<8;u++)
               {
                    if(pro[i][1]==TT[0][u])
                    {
                         TT[j][u]="1";
                    }
               }
          }
     }
}

for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(TT[i][j]==null)
          {
               TT[i][j]="0";
          }
     }
}
System.out.println();
System.out.println("First Matrix");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TT[i][j]+"");
     }
     System.out.println();
}

for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          TTp[i][j]=TT[i][j];
     }
}
for(i=1;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(TTp[j][i]=="1")
          {
               for(u=1;u<8;u++)
               {
                    b1=Integer.parseInt(TTp[j][u]);
                    b=Integer.parseInt(TTp[i][u]);
                    b1=b1+b;
                    TTp[j][u]=String.valueOf(b1);
               }
               b1=0;
               b=0;
          }

     }
}
System.out.println();
System.out.println("First+ Matrix:-");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TTp[i][j]+"");
     }
     System.out.println();
}

for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(i==j)
          {
               id[i][j]="1";
          }
          else
          {
               id[i][j]="0";
          }
     }
}

TTs[0][0]=(" ");
for(k=1;k<8;k++)
{
     TTs[k][0]=T[k];
     TTs[0][k]=T[k];
}
for(i=1;i<8;i++)
{
     for(j=1;j<8;j++)
     {
          c=Integer.parseInt(TTp[i][j]);
          c1=Integer.parseInt(id[i][j]);
          c2=c+c1;
          TTs[i][j]=String.valueOf(c2);
     }
     c=0;
     c1=0;
     c2=0;
}
System.out.println();
System.out.println("First* Matrix");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TTs[i][j]+"");
     }
     System.out.println();
}
TT1[0][0]=(" ");
for(k=1;k<8;k++)
{
     TT1[k][0]=T[k];
     TT1[0][k]=T[k];     
}
for(i=0;i<4;i++)
{
     for(j=0;j<8;j++)
     {
          if(pro[i][0]==TT1[j][0])
          {
               for(u=0;u<8;u++)
               {
                    if(pro[i][m].equals(""))
                    {
                         m=m-1;
                    }          
                    else
                    {
                         if(pro[i][m]==TT1[0][u])
                         {
                              TT1[j][u]="1";
                         }
                    }     
               }
               m=3;
          }
     }
}
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(TT1[i][j]==null)
          {
               TT1[i][j]="0";
          }
     }
}
System.out.println();
System.out.println("Last Matrix:-");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TT1[i][j]+"");
     }
     System.out.println();
}
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          TT1p[i][j]=TT1[i][j];
     }
}
for(i=1;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(TT1p[j][i]=="1")
          {
               for(u=1;u<8;u++)
               {
                    b1=Integer.parseInt(TT1p[j][u]);
                    b=Integer.parseInt(TT1p[i][u]);
                    b1=b1+b;
                    TT1p[j][u]=String.valueOf(b1);
               }
               b1=0;
               b=0;
          }
     }
}
System.out.println();
System.out.println("Last+ Matrix:-");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TTp[i][j]+"");
     }
     System.out.println();
}
TT1s[0][0]=(" ");
for(k=1;k<8;k++)
{
     TT1s[k][0]=T[k];
     TT1s[0][k]=T[k];
}
for(i=1;i<8;i++)
{
     for(j=1;j<8;j++)
     {
          c=Integer.parseInt(TT1p[i][j]);
          c1=Integer.parseInt(id[i][j]);
          c2=c+c1;
          TT1s[i][j]=String.valueOf(c2);
     }
     c=0;
     c1=0;
     c2=0;
}

System.out.println();
System.out.println("Last* matrix");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TT1s[i][j]+"");
     }
     System.out.println();
}
pro1[0][0]="Z";
pro1[0][1]="b";
pro1[0][2]="M";
pro1[0][3]="b";

pro1[1][0]="M";
pro1[1][1]="a";
pro1[1][2]="";
pro1[1][3]="";


pro1[2][0]="L";
pro1[2][1]="M";
pro1[2][2]="a";
pro1[2][3]=")";


pro1[3][0]="M";
pro1[3][1]="(";
pro1[3][2]="L";
pro1[3][3]="";

TTe[0][0]=(" ");
for(k=1;k<8;k++)
{
     TTe[k][0]=T[k];
     TTe[0][k]=T[k];
}

for(i=0;i<4;i++)
{
     for(j=2;j<4;j++)
     {
          if(pro1[i][j]!=null)
          {
               for(s=0;s<4;s++)
               {
                    for(t=0;t<8;t++)
                    {
                         if(pro1[s][1]==TTe[t][0])
                         {
                              for(v=0;v<8;v++)
                              {
                                   if(pro1[s][2]==TTe[0][v])
                                   {
                                        TTe[t][v]="1";
                                        if(pro1[i][3]!=null)
                                        {
                                        for(w=0;w<4;w++)
                                        {
                                             for(x=0;x<8;x++)
                                             {
                                             if(pro1[w][2]==TTe[x][0])
                                             {
                                             for(y=0;y<8;y++)
                                             {
                                             if(pro1[w][3]==TTe[0][y])
                                             {
                                             TTe[x][y]="1";
                                             }
                                             }
                                             }
                                             }
                                        }
                                        }
                                   }
                              }
                         }
                    }
               }
          }
     }
}

for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(TTe[i][j]==null)
          {
               TTe[i][j]="0";
          }
     }
}
System.out.println();
System.out.println("Equal Matrix:-");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TTe[i][j]+"");
     }
     System.out.println();
}

TTless[0][0]=(" ");
for(k=1;k<8;k++)
{
     TTless[k][0]=T[k];
     TTless[0][k]=T[k];
}
g=0;
for(i=1;i<8;i++)
{
     for(j=1;j<8;j++)
     {
          g1=0;
          e=0;
          f=0;
          for(a=1;a<8;a++)
          {
               e=Integer.parseInt(TTe[i][a]);
               f=Integer.parseInt(TTp[a][j]);
               g=e*f;
               g1=g1+g;
          }
          TTless[i][j]=String.valueOf(g1);     
     }
}
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(TTless[i][j]==null)
          {
               TTless[i][j]="0";
          }
     }
}
System.out.println();
System.out.println("Less than Matrix:- ");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TTless[i][j]+"");
     }
     System.out.println();
}
TTgre[0][0]=(" ");
for(k=1;k<8;k++)
{
     TTgre[k][0]=T[k];
     TTgre[0][k]=T[k];
}
TTgre1[0][0]=(" ");
for(k=1;k<8;k++)
{
     TTgre1[k][0]=T[k];
     TTgre1[0][k]=T[k];
}
for(i=1;i<8;i++)
{
     for(j=1;j<8;j++)
     {
          n1=0;
          n=0;
          h=0;
          l=0;
          for(a=1;a<8;a++)
          {
               h=Integer.parseInt(TT1p[a][i]);
               l=Integer.parseInt(TTe[a][j]);
               n=h*l;
               n1=n1+n;
          }
          TTgre1[i][j]=String.valueOf(n1);
     }
}
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(TTgre1[i][j]==null)
          {
               TTgre1[i][j]="0";
          }
     }
}
for(i=1;i<8;i++)
{
     for(j=1;j<8;j++)
     {     
          n3=0;
          n2=0;
          h1=0;
          l1=0;
          for(a=1;a<8;a++)
          {
               h1=Integer.parseInt(TTgre1[i][a]);
               l1=Integer.parseInt(TTs[a][j]);
               n2=h1*l1;
               n3=n3+n2;
          }
          TTgre[i][j]=String.valueOf(n3);
     }
}
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(TTgre[i][j]==null)
          {
               TTgre[i][j]="0";
          }
     }
}
System.out.println();
System.out.println("Greater than matrix:- ");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TTgre[i][j]+"");
     }
     System.out.println();
}

TTspm[0][0]=(" ");
for(k=1;k<8;k++)
{
TTspm[k][0]=T[k];
TTspm[0][k]=T[k];
}
for(i=1;i<8;i++)
{
     for(j=1;j<8;j++)
     {
          if(TTless[i][j].equals("1"))
          {
               TTspm[i][j]="<";
          }
          if(TTgre[i][j].equals("1"))
          {
               TTspm[i][j]=">";
          }
          if(TTe[i][j].equals("1"))
          {
               TTspm[i][j]="=";
          }
     }
}
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          if(TTspm[i][j]==null)
          {
               TTspm[i][j]="0";
          }
     }
}
System.out.println();
System.out.println("SPM Matrix:- ");
System.out.println();
for(i=0;i<8;i++)
{
     for(j=0;j<8;j++)
     {
          System.out.print(""+TTspm[i][j]+"");
     }
System.out.println();
}
    }

}          
Comments: