#include <mpi.h>
#include <stdio.h>
int main ( int argc, char *argv[] ) {
	int ProcNum, ProcRank, tmp;
	MPI_Status status;
	MPI_Init ( &argc, &argv );
	MPI_Comm_size ( MPI_COMM_WORLD, &ProcNum);
	MPI_Comm_rank ( MPI_COMM_WORLD, &ProcRank);
	if(ProcRank == 0){
		printf("Hello world from process %i \n", ProcRank);
		for(int i = 1; i < ProcNum; i++){
			MPI_Recv(&tmp,1,MPI_INT,MPI_ANY_SOURCE,0,MPI_COMM_WORLD, &status);
			printf("Hello world from process %i \n", tmp);
		}
	}else{
		MPI_Send(&ProcRank,1,MPI_INT,0,0,MPI_COMM_WORLD);
	}
	MPI_Finalize();
	return 0;
}
