bully



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);
}
}
}






Leave a Reply