#include <stdio.h>
#include <mpi.h>
struct twovector {
    int x;int y;
};
int main(int argc, char *argv[]) {
    int rank;
    int A_tag=7;
    MPI_Status status;
    struct twovector v1[2],v2[2];
    MPI_Datatype two_vector;
    MPI_Init(&argc,&argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
    MPI_Type_contiguous(2,MPI_INT,&two_vector);
    MPI_Type_commit(&two_vector);
    if (rank==0) {
        v1[0].x=1;v1[0].y=2;
        v1[1].x=3;v1[1].y=4;
        MPI_Send(&v1,2,two_vector,1,A_tag,MPI_COMM_WORLD);
    } else if (rank==1) {
        MPI_Recv(&v2,2,two_vector,0,A_tag,MPI_COMM_WORLD,&status);
        printf("Task:%d received 2 two vectors the second is [%d,%d] \n",rank,v2[1].x,v2[1].y);
    }
    MPI_Finalize();
    return 0;
}