Exemple #1
0
int main(int argc, char** argv)  
{ 
  double      t0, t1, dat= 0.0, dat1, dat_rec; 
  int         pid, i; 
  MPI_Status  status; 
  MPI_Init(&argc, &argv); 
  MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
  if (pid == 0) t0 = MPI_Wtime(); 
  for(i=0; i<VUELTAS; i++)  
  { 
    if (pid == 0)  
    { 
      MPI_Ssend(&dat, 1, MPI_DOUBLE, 1, 0, MPI_COMM_WORLD); 
      dat1 = calculo(); 
      MPI_Recv(&dat_rec, 1, MPI_DOUBLE, 1, 0, MPI_COMM_WORLD, &status); 
      dat = dat1 + dat_rec; 
    }  
    else  
    {    
      dat1 = calculo(); 
      MPI_Recv(&dat_rec, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &status); 
      dat = dat1 + dat_rec; 
      MPI_Ssend(&dat, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); 
    } 
  } 
  if (pid == 0)  
  { 
    t1 = MPI_Wtime(); 
    printf("\n   Tiempo de ejecucion = %f s \n", t1-t0); 
    printf("\n   Dat = %1.3f \n\n", dat); 
  } 
  MPI_Finalize(); 
  return 0; 
} /*  main  */ 
Exemple #2
0
//--------------------------------------------------------------
void testApp::setup(){
    for(uint_fast8_t i=0;i<ANCHO;i++){
        for(uint_fast8_t e=0;e<ALTO;e++){
            matriz[i][e].x=i;
            matriz[i][e].y=e;
            matriz[i][e].valor=0;

            if(e+2<ALTO && i-1>=0) matriz[i][e].mov.push_back(&matriz[i-1][e+2]);
            if(e+2<ALTO && i+1<ANCHO) matriz[i][e].mov.push_back(&matriz[i+1][e+2]);
            if(e+1<ALTO && i-2>=0) matriz[i][e].mov.push_back(&matriz[i-2][e+1]);
            if(e+1<ALTO && i+2<ANCHO) matriz[i][e].mov.push_back(&matriz[i+2][e+1]);
            if(e-1>=0 && i-2>0) matriz[i][e].mov.push_back(&matriz[i-2][e-1]);
            if(e-1>=0 && i+2<ANCHO) matriz[i][e].mov.push_back(&matriz[i+2][e-1]);
            if(e-2>=0 && i-1>=0) matriz[i][e].mov.push_back(&matriz[i-1][e-2]);
            if(e-2>=0 && i+1<ANCHO) matriz[i][e].mov.push_back(&matriz[i+1][e-2]);
        }
    }
    calculo(&matriz[1][0],1); //Current Number debe comenzar en 1 !

    //Visualizacion
    ofBackground(0,255);
    ofSetBackgroundAuto(true);
    myfont.loadFont("arial.ttf", 10);
    ofNoFill();
}
Exemple #3
0
int main()
{
    entrada();
	calculo(a);
	imprime();
	return 0;
}
void main(){

 calculo();



}
Exemple #5
0
int main(int argc, char const *argv[])
{
	char texto[200],nombre[200];
	double start, end,seconds;
	start=CurrentTime();
	char *t1,*t2,*t3;
	char *resp;
	int i; 
	system("clear");
	FILE *archivo1=NULL,*archivo2=NULL;
	resp=strstr( argv[2], ".txt" );
	if(resp==NULL){
   		error(3);
   	}
	if(argc==3&&strcmp(argv[1],"-FILE")==0){
		if((archivo1=fopen(argv[2],"r"))==NULL){
			error(1);
		}
		do{
		fscanf(archivo1,"%[^\n\r]\n|\r",texto);
		
			
			t1=strtok(texto,"\t");
			t2=strtok(NULL,"\t");
		sprintf(nombre, "./MainHaus -FILES %s %s",t1,t2);
		printf("%s-%s\n", t1,t2);
			for (i = 0; i < 31; ++i)
			{
				system(nombre);
				anilizaerror();
			}
			
			t3=strtok(t1,".");
			sprintf(nombre, "%s",t3);
			t3 = strtok(t2,".");
			sprintf(nombre, "%s_%s.out",nombre,t3);
			if((archivo2=fopen(nombre,"r"))==NULL){
			error(1);
			}
			for (i = 0; i <31; ++i)
			{
				fscanf(archivo2,"%[^\n]\n",texto);
				vector[i]=atof(strtok(texto,"\t"));
			}
			calculo();
			guardar_archivo();	
		 	printf("\n");
			

		}while(!feof(archivo1));		
		fclose(archivo1);

	}else{error(2);}

	end=CurrentTime();
	seconds=(end-start);
	printf("Segundos: %.5f\tReloj de computadora:%.10f\n",seconds,seconds/(double)CLOCKS_PER_SEC);
	return 0;
}
Exemple #6
0
int main (){
    srand(time(NULL));
    float resultado, dato1=rand()% 11, dato2=rand()% 11;
    resultado = calculo(dato1, dato2);
    printf("El resultado es %f", resultado);
    system("pause");
    return 0;
}
void recebe ()
{
	int aux=0, aux2=1,c=0, num;
	printf("Informe valor: ");
	scanf("%d",&num );
	
	calculo(&aux, &aux2, &c, &num);	
	return;
}
Exemple #8
0
int main()
{
	int aux=0, aux2=1,c=0, num;
	printf("Informe valor: ");
	num= 4000000;
	
	calculo(&aux, &aux2, &c, &num);
	
	system("pause");
	return 0;
}
Exemple #9
0
int main (int argc,char *argv[]){

    double numero1, numero2;

    printf(" Introduce un numero:   ");
    scanf(" %lf", &numero1);
     
    printf(" Introduce un segundo  numero:   ");
    scanf(" %lf", &numero2);
   

    calculo(numero1,numero2);
    printf("\n");

	    return EXIT_SUCCESS;
	    } 
Exemple #10
0
bool testApp::calculo(celda* cell, uint_fast8_t currentNumber){
    cell->valor=currentNumber;
    for(uint_fast8_t i=0;i<cell->mov.size(); i++){
        if((cell->mov[i]->valor==0) && calculo(cell->mov[i], currentNumber+1)){
            pos[currentNumber-1]=cell;
            return true;
        }
    }
    if(currentNumber==ultimoNumero) {
        pos[ultimoNumero-1]=cell;
        cell->valor=ultimoNumero;
        return true;
    }
    cell->valor=0;
    return false;
}
int main(int argc, char *argv[])
{
    	int i,N;
	extern char *optarg;			//arreglo definido por getopt
  	int opcion, error = 0;			// variables para el switch (opcion que se elige) y para un posible error respectivamente
  	int esta_f = 0;		// iniciamos variables para detectar si estan o no f
  	char texto[100];
	char numero[10];
	while((opcion = getopt(argc, argv, "f:"))!=-1)	// while para recibir los argumento del argv
  		switch (opcion){
  			case 'f':
  				esta_f = 1;	//registramos que había una f
				strcpy (texto,optarg);  				
				break;
  			case '?':
  				error = 1;	//marcamos que hubo un error en la sintaxis de entrada
  				break;
  		}
  	if (esta_f == 0){			
  		printf("falta ingresar f \n");
  	}
  	if (error == 1){			// si encontramos algun error en la sintaxis
  		printf("error de sintaxis");
  	}
	
	FILE *archivo;
	archivo = fopen(texto,"r");
	
	if (archivo == NULL){
 
		printf("\nError de apertura del archivo. \n\n");
        }else{
	    while (feof(archivo) == 0)
	    {	
		fscanf(archivo,"%s",numero);
		
	    }
        }
	N = atoi(numero);
    	float vector[N];		//vector de tamaño N
   	for(i = 0; i < N; i++){		//para inicializar el vector
        	vector[i] = i + 1;
    	}

    	printf("%f\n", calculo(N,vector)); //llamada a la funcion calculo
    	return 0;
}
void odomCallback(const nav_msgs::OdometryConstPtr &var)
{
    // Copy from received message
    qt = var->pose.pose.orientation;
    qp = var->pose.pose.position;
    // Define double
    double yaw = tf::getYaw(qt);
    // Print to screen result
    
    std::cout << "Yaw: " << yaw;
    std::cout << " Position x : " << qp.x;
    std::cout << " Position y : " << qp.y << std::endl;
    
    geometry_msgs::Point P = LinhaePonto(qp.x,qp.y);  
    calculo(qp.x,qp.y, yaw, P.x, P.y);
    
 
    
}
Exemple #13
0
void aplicar_filtro_1(Imagem* modificada, Imagem* original) {
    int width;
    int height;
    int i;
    int j;
    int k;
    int m;
    int r;
    int g;
    int b;
    int acc;

    height = original->height;
    width = original->width;

    for (i = 1; i < height - 1; ++i) {
        for (j = 1; j < width - 1; ++j) {
            calculo(modificada, original, i, j);
        }
    }
}
Exemple #14
0
int main()
{
	imprime(calculo(entrada()));
	return 0;
}
Exemple #15
0
int main(int argc, char** argv) {
  TOTAL = calculo();

  printf("Total: %d\n", TOTAL);
  return (0);
}