fork download
  1. #include <stdio.h>
  2. #include <mpi.h>
  3.  
  4. int main(int argc, char *argv[]) {
  5. int rank, size;
  6.  
  7. MPI_Init(&argc, &argv);
  8. MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  9. MPI_Comm_size(MPI_COMM_WORLD, &size);
  10.  
  11. double X[] = {2, 1};
  12. double Y[] = {-1, -2};
  13. double m, c;
  14.  
  15. if (rank == 0) {
  16. // Calculam panta (m)
  17. m = (Y[1] - Y[0]) / (X[1] - X[0]);
  18. }
  19.  
  20. MPI_Bcast(&m, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
  21.  
  22. // Calculam coeficientul de interceptare (c) folosind punctul A
  23. c = Y[0] - m*X[0];
  24.  
  25. if (rank == 0) {
  26. printf("Ecuatia dreptei care trece prin punctele A(2,-1) si B(1,-2) este: y = %.2fx + %.2f
  27. ", m, c);
  28. }
  29.  
  30. MPI_Finalize();
  31.  
  32. return 0;
  33. }
Success #stdin #stdout #stderr 0.34s 40288KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: unexpected symbol in "int main"
Execution halted