#include <stdio.h>
#include <mpi.h>
int main(int argc, char* argv[]) {
 MPI_Init(&argc, &argv);
 int size, my_rank;
 MPI_Comm_size(MPI_COMM_WORLD, &size); // Get the total number of processes
 MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); // Get the rank of the current process
 int my_values[5]; // Array to hold values for each process
 for (int i = 0; i < 5; i++) {
 my_values[i] = (my_rank + 1* 100 ; // Initialize array with unique values based on rank
 }
 // Print the values before MPI_Alltoall
 printf("Process %d, my_values: %d, %d, %d, %d, %d.\n",
 my_rank, my_values[0], my_values[1], my_values[2], my_values[3], my_values[4]);
 int buffer_recv[5]; // Array to receive data from all other processes
 // Perform the MPI_Alltoall operation
 MPI_Alltoall(my_values, 1, MPI_INT, buffer_recv, 1, MPI_INT, MPI_COMM_WORLD);
 // Print the values received by each process
 printf("Process %d, received values: %d, %d, %d, %d, %d.\n",
 my_rank, buffer_recv[0], buffer_recv[1], buffer_recv[2], buffer_recv[3], buffer_recv[4]);
 MPI_Finalize();
 return 0;
}

