Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
t
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; public class Multithread { public static void main(String[] args) { Multithreadingdemo o=new Multithreadingdemo(); o.start(); } } class Multithreadingdemo extends Thread { public void run() { Scanner sc=new Scanner(System.in); int s=0,n=4,row=4,k=1,w=0,e=0; String z="A",g="B"; String a[][]=new String[n][row]; for(int i=0;i<n;i++) { for(int j=0;j<row;j++) { a[i][j]="_"; } } while(k!=0) { System.out.println("Enter Team name"); String x=sc.next(); for(int i=0;i<n;i++) { for(int j=0;j<row;j++) { if(a[i][j]=="_" && j!=3) { a[i][j]=x; s=1; break; } if(j==3 && a[i][j]=="_") { for(int h=0;h<row-1;h++) { if(a[i][h].equals(x)) w++; else e++; } } if(e>w && w!=0 && e!=0) { a[i][j]=x; s=1; break; } else if(w==0 || e==0) { if(e==0) { a[i][j]=x; s=1; break; } else j=0; if(a[i+1][j]=="_") a[i+1][j]=x; else a[i+1][j+1]=x; s=1; break; } else { j=0;break; } } } w=0; e=0; if(s==1) { s=0;break; } } for(int i=0;i<n;i++) { for(int j=0;j<4;j++) { System.out.print(a[i][j]+" "); } System.out.println(); } System.out.println("Conti Y-N?"); String r="Y",rr="N"; String gg=sc.next(); if(gg.equals(rr)) k=0; } }
run
|
edit
|
history
|
help
0
Leetcode 202 Happy Number
Consecutive Elements String
final method
Quadratic equation
1 to 100 except 30 to40
Java messing around
Klamry dla Andy'ego
Lexisort
2A
test1