Import Java.util.Scanner;
public class ZHSH_NHH extends thread{
/**
* @param args
*/
private int n,start,end;
public int q;
public int[][] zhshq=new int[10000][22];
int[] B=new int[22];
public zhsh_nhh (int x,int start,int end)
{
this.q=0;
this.start=start;
this.end=end;
this.n=x;
}
public void out (int ans)
{
for (int i=1;i<=n;i++)
{
for (int j=1;j<=n;j++)
if (zhshq[ans-1][i]==j)
system.out.print (' Q ');
else System.out.print (' * ');
system.out.print (' \ n ');
}
}
public void Dfs (int k,int b[])
{
if (k>n)
{
q++;
System.out.println (q+ "ddddddddddddd");
for (int l=1;l<=n;l++)
ZHSHQ[Q][L]=B[L];
return;
}
int i,j;
for (i=1;i<=n;i++)
{
for (j=1;j<k;j++)
{
if (I==b[j])
Break
if (Math.Abs (k-j) ==math.abs (I-b[j]))
Break
}
if (j<k)
Continue
System.out.print ("Grass mud Horse" +i);
B[k]=i;
DFS (K+1,B);
}
}
public void Run ()
{
System.out.print ("Start running Me");
for (int i=start;i<=end;i++)
{
B[1]=i;
DFS (2,B);
}
}
public static void Main (string[] args) throws Interruptedexception {
TODO auto-generated Method Stub
Scanner zhshinput=new Scanner (system.in);
int Zhshn=zhshinput.nextint ();
Parallel solution
Long k=0;
Long Begin,end,endend;
Parallel solution
ZHSH_NHH t1=new zhsh_nhh (ZHSHN,1,ZHSHN/2);
ZHSH_NHH t2=new zhsh_nhh (ZHSHN,ZHSHN/2+1,ZHSHN);
Begin=system.currenttimemillis ();
T1.start ();
T2.start ();
T1.join ();
T2.join ();
End=system.currenttimemillis ();
Serial Solution
ZHSH_NHH t=new zhsh_nhh (ZHSHN,1,ZHSHN);
Long B=system.currenttimemillis ();
T.start ();
T.join ();
Endend=system.currenttimemillis ();
SYSTEM.OUT.PRINTLN ("Parallel Time is");
System.out.println (End-begin);
System.out.println ("Serial Time Is");
System.out.println (Endend-b);
System.out.println ("acceleration ratio:" + (Endend-b) *1.0/(end-begin) *1.0);
System.out.println ("A total of" +t.q+ "solution");
int x;
int ans;
System.out.println ("Please enter solution method of the required solution: \ n 1 Serial solution \ n 2: Parallel solution \ n 0: Exit");
X=zhshinput.nextint ();
while (x>0)
{
System.out.println ("Please enter the method of Solution:");
Ans=zhshinput.nextint ();
if (ANS>T.Q)
SYSTEM.OUT.PRINTLN ("Input error data");
if (x==2)
{
if (ANS<=T1.Q)
T1.out (ANS);
Else
T2.out (ANS-T1.Q);
}
else if (x==1)
{
T.out (ANS);
}
else System.out.println ("incorrect data entered \ n");
System.out.println ("Please enter solution method of the required solution: \ n 1 Serial solution \ n 2: Parallel solution \ n 0: Exit");
}
}
}
Java jobs cannot be run