“Kompiler C online dengan MPI” Kode Jawaban

Kompiler C online dengan MPI

#include <stdio.h>
#include <mpi.h>

using namespace std;

int main( int argc, char ** argv)
{
	int rank, size;
	MPI_Init(&argc, &argv);
	MPI_Comm_size(MPI_COMM_WORLD, &size);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	

	char message[255];
	char nadawanie[255];
	
	if(rank==0)
		{
			cin>>nadawanie;
			MPI_Send(&nadawanie, 255, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
		}
	else if(rank == 1)
		{
			MPI_Recv(&message, 255, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD_ MPI_STATUS_IGNORE);
			cout << message << endl;
		}

}
Disgusted Dotterel

Kompiler C online dengan MPI

#include<stdio.h>
int main()
{
    int p,i,j,n,c=0;
    float d[20],b[20],a[20][20],e[20][20],output;
    printf("\n Enter the DIMENSION of the MATRIX A : ");
    scanf("%d",&n);
    printf("\n|----- NOTE : Enter the elements of matrix ROW-WISE* -----|\n");
    printf("\nEnter elements of MATRIX A :\n");
    for(p=0;p<n;p++)
    {
   	 for(i=0;i<n;i++)
   	 {
   		 scanf("%f",&a[p][i]);
   	 }
    }
    printf("\nEnter elements of MATRIX B :\n");
    for(p=0;p<n;p++)
    {
   	 scanf("%f",&b[p]);
    }
    for(j=0;j<n-1;j++)
    {
   	 if(a[j][j]==0)
   	 {
   		 printf("*This equation is NOT solvable by the Gaussian-elimination method...!* \n");
   		 return 1;
   	 }
   	 for(p=j+1;p<n;p++)
   	 {
   		 e[p][j]=a[p][j]/a[j][j];
   		 c++;
   	 }
   	 for(p=j+1;p<n;p++)
   	 {
   		 for(i=j+1;i<n;i++)
   		 {
   			 a[p][i]=a[p][i]-e[p][j]*a[j][i];
   			 c++;
   		 }
   		 b[p]=b[p]-e[p][j]*b[j];
   		 c++;
   		 a[p][j]=0;
   	 }
    }
    printf("\nAfter the conversion\n");
    printf("\nMatrix A(%dx%d) and Matrix B(%dx1) will be : \n",n,n,n);
    for(p=0;p<n;p++)
    {
   	 for(i=0;i<n;i++)
   	 {
   		 printf("%.4f  ",a[p][i]);
   	 }
   	 printf("%.4f \n",b[p]);
   	 }
   	 printf("\n Output  : ");
   	 d[n-1]=b[n-1]/a[n-1][n-1];
   	 c++;
   	 for (p=n-2;p>=0;p--)
   	 {
   		 output = 0.0;
   		 for(i=p+1;i<n;i++)
   		 {
   			 output=output+a[p][i]*d[i];
   			 c++;
   		 }
   		 d[p]=(b[p]-output)/a[p][p];
   		 c++;
   	 }
   	 for(p=0;p<n;p++)
   	 {
   		 printf("%.4f  ",d[p]);
   	 }
   	 return 0;
}
Attractive Anaconda

Kompiler C online dengan MPI


#include <omp.h>
 
#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char* argv[])
{
 
    {
 
        printf("Hello World... from thread = %d\n",
               omp_get_thread_num());
    }
   
}
Hurt Hawk

Kompiler C online dengan MPI

#include<stdio.h>
int main()
{
    int p,i,j,n,c=0;
    float d[20],b[20],a[20][20],e[20][20],output;
    printf("\n Enter the DIMENSION of the MATRIX A : ");
    scanf("%d",&n);
    printf("\n|----- NOTE : Enter the elements of matrix ROW-WISE* -----|\n");
    printf("\nEnter elements of MATRIX A :\n");
    for(p=0;p<n;p++)
    {
   	 for(i=0;i<n;i++)
   	 {
   		 scanf("%f",&a[p][i]);
   	 }
    }
    printf("\nEnter elements of MATRIX B :\n");
    for(p=0;p<n;p++)
    {
   	 scanf("%f",&b[p]);
    }
    for(j=0;j<n-1;j++)
    {
   	 if(a[j][j]==0)
   	 {
   		 printf("*This equation is NOT solvable by the Gaussian-elimination method...!* \n");
   		 return 1;
   	 }
   	 for(p=j+1;p<n;p++)
   	 {
   		 e[p][j]=a[p][j]/a[j][j];
   		 c++;
   	 }
   	 for(p=j+1;p<n;p++)
   	 {
   		 for(i=j+1;i<n;i++)
   		 {
   			 a[p][i]=a[p][i]-e[p][j]*a[j][i];
   			 c++;
   		 }
   		 b[p]=b[p]-e[p][j]*b[j];
   		 c++;
   		 a[p][j]=0;
   	 }
    }
    printf("\nAfter the conversion\n");
    printf("\nMatrix A(%dx%d) and Matrix B(%dx1) will be : \n",n,n,n);
    for(p=0;p<n;p++)
    {
   	 for(i=0;i<n;i++)
   	 {
   		 printf("%.4f  ",a[p][i]);
   	 }
   	 printf("%.4f \n",b[p]);
   	 }
   	 printf("\n Output  : ");
   	 d[n-1]=b[n-1]/a[n-1][n-1];
   	 c++;
   	 for (p=n-2;p>=0;p--)
   	 {
   		 output = 0.0;
   		 for(i=p+1;i<n;i++)
   		 {
   			 output=output+a[p][i]*d[i];
   			 c++;
   		 }
   		 d[p]=(b[p]-output)/a[p][p];
   		 c++;
   	 }
   	 for(p=0;p<n;p++)
   	 {
   		 printf("%.4f  ",d[p]);
   	 }
   	 return 0;
}
Attractive Anaconda

Kompiler C online dengan MPI

#include<stdio.h>
int main()
{
    int p,i,j,n,c=0;
    float d[20],b[20],a[20][20],e[20][20],output;
    printf("\n Enter the DIMENSION of the MATRIX A : ");
    scanf("%d",&n);
    printf("\n|----- NOTE : Enter the elements of matrix ROW-WISE* -----|\n");
    printf("\nEnter elements of MATRIX A :\n");
    for(p=0;p<n;p++)
    {
   	 for(i=0;i<n;i++)
   	 {
   		 scanf("%f",&a[p][i]);
   	 }
    }
    printf("\nEnter elements of MATRIX B :\n");
    for(p=0;p<n;p++)
    {
   	 scanf("%f",&b[p]);
    }
    for(j=0;j<n-1;j++)
    {
   	 if(a[j][j]==0)
   	 {
   		 printf("*This equation is NOT solvable by the Gaussian-elimination method...!* \n");
   		 return 1;
   	 }
   	 for(p=j+1;p<n;p++)
   	 {
   		 e[p][j]=a[p][j]/a[j][j];
   		 c++;
   	 }
   	 for(p=j+1;p<n;p++)
   	 {
   		 for(i=j+1;i<n;i++)
   		 {
   			 a[p][i]=a[p][i]-e[p][j]*a[j][i];
   			 c++;
   		 }
   		 b[p]=b[p]-e[p][j]*b[j];
   		 c++;
   		 a[p][j]=0;
   	 }
    }
    printf("\nAfter the conversion\n");
    printf("\nMatrix A(%dx%d) and Matrix B(%dx1) will be : \n",n,n,n);
    for(p=0;p<n;p++)
    {
   	 for(i=0;i<n;i++)
   	 {
   		 printf("%.4f  ",a[p][i]);
   	 }
   	 printf("%.4f \n",b[p]);
   	 }
   	 printf("\n Output  : ");
   	 d[n-1]=b[n-1]/a[n-1][n-1];
   	 c++;
   	 for (p=n-2;p>=0;p--)
   	 {
   		 output = 0.0;
   		 for(i=p+1;i<n;i++)
   		 {
   			 output=output+a[p][i]*d[i];
   			 c++;
   		 }
   		 d[p]=(b[p]-output)/a[p][p];
   		 c++;
   	 }
   	 for(p=0;p<n;p++)
   	 {
   		 printf("%.4f  ",d[p]);
   	 }
   	 return 0;
}
Attractive Anaconda

Jawaban yang mirip dengan “Kompiler C online dengan MPI”

Pertanyaan yang mirip dengan “Kompiler C online dengan MPI”

Lebih banyak jawaban terkait untuk “Kompiler C online dengan MPI” di C

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya