title: How to generate an array in each process and in these processes find the minimum value of its generated part
body: <p>I need generate an array in each process and in these processes find the minimum value of its generated part.I do not understand how to divide the generation into parts and find the minimum value in these parts.</p>
  <pre><code>int rank, num_procs;
  double result;
  int length = 10e6;
  double *arr = new double[length];
  MPI_Init(&amp;argc, &amp;argv);
  MPI_Comm_size(MPI_COMM_WORLD, &amp;num_procs);
  MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
  
  int load = length / num_procs;
  auto min = DBL_MAX, max = DBL_MIN;
  for (int i = rank * load; i &lt; (rank + 1) * load; ++i) {
      arr[i] = (pow(2 * i, 1 / 3) + 6) / abs(i * cos(i));
      if (arr[i] &gt; max) {
          max = arr[i];
      } 
      if (arr[i] &lt; min) {
          min = arr[i];
      }
  }
  result = min * max;
  cout &lt;&lt; result &lt;&lt; endl;
  MPI_Send(&amp;result, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
  
  if (rank == 0) {
      MPI_Recv(&amp;result, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD,
               MPI_STATUS_IGNORE);
      result *= result;
      cout &lt;&lt; result &lt;&lt; endl;
  }
  </code></pre>