import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Bully {
static int n,pc,in;
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br=new BufferedReader(new InputStreamReader (System.in));
System.out.println("Enter the Number of Clients");
n=Integer.parseInt(br.readLine());
System.out.println("Enter the Pri-Coordinator");
pc=Integer.parseInt(br.readLine());
System.out.println("Enter the Introducer");
in=Integer.parseInt(br.readLine());
for(int i=in;i<n;)
{
System.out.println(in+"Send the Election messege to "+ ++i);
}
for(int i=n;i>in;i--)
{
if(i!=pc)
System.out.println(i +"Send the Ok messege to "+ in);
}
for(int i=in+1;i<=n;i++)
{
if(i!=pc)
System.out.println(i +"Send the Election messege to "+ pc);
}
for(int i=n;i>=1;i--)
{
if(i!=pc && i>=i-1)
{
System.out.println("The new Co-ordinator is Selected."+i);
pc=i;
break;
}
}
for(int i=1;i<=n;i++)
{
if(i!=pc)
System.out.println("The new Co-ordinator "+pc+" is Send the ok Messege to ."+i);
}
}
}
Written by Naresh in
bully
Popular Posts
-
import java.io.*; import java.net.*; import java.util.Scanner; /** Fetches the HTML content of a web page (or HTTP header) as a String....
-
import java.util.*; import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; class common extends Panel im...
-
Calculator.java public interface Calculator extends java.rmi.Remote { public long add(long a,long b) throws java.rmi.RemoteException; ...
-
Client import java.io.*; import java.net.*; class client { public static void main(String args[])throws Exception { String str;...
-
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Bully { static int n,pc,in...
-
import java.net.*; import java.io.IOException; import javax.swing.*; public class Trial { public static void main(String args[]) { ...
-
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Ring { static int n,pc,i...