Beispiel #1
0
int captura( int i, int j ){
    
    int cap, ret;
    int old = peca[i][j];
	peca[i][j] = 0;
	ret = 0;
	
	if( (i+2) < linhas ){
		if( j+2 < colunas ){
			if( peca[i+1][j+1] == 2 && peca[i+2][j+2] == 0 ){
				peca[i+1][j+1] = 0;
				cap = 1 + captura( i+2, j+2 );
				if( cap > ret ) ret = cap;
				peca[i+1][j+1] = 2;
			}
		}	
			
		if( j - 2 >= 0 ){
			if( peca[i+1][j-1] == 2 && peca[i+2][j-2] == 0 ){
				peca[i+1][j-1] = 0;
				cap = 1 + captura( i+2, j-2 );
				if( cap > ret ) ret = cap;
				peca[i+1][j-1] = 2;
			}
		}
	}
	
	if( (i-2) >= 0 ){
		
		if( j+2 < colunas ){
			if( peca[i-1][j+1] == 2 && peca[i-2][j+2] == 0 ){
				peca[i-1][j+1] = 0;
				cap = 1 + captura( i-2, j+2 );
				if( cap > ret ) ret = cap;
				peca[i-1][j+1] = 2;
			}
		}
		
			
		if( j - 2 >= 0 ){
			if( peca[i-1][j-1] == 2 && peca[i-2][j-2] == 0 ){
				peca[i-1][j-1] = 0;
				cap = 1 + captura( i-2, j-2 );
				if( cap > ret ) ret = cap;
				peca[i-1][j-1] = 2;
			}
		}
	}
	
	
	peca[i][j] = old;
    return ret;
}
list<capturas> gerenciadorCapturas::getListaCapturaPorIndividuo(int idIndividuo){
	int posFimArquivo = LED->getPosFimArquivo();
	int pos = 0;
	list<capturas> listaDeCapturas;	

	while(posFimArquivo > 0){
		// Carrega tamanho do registro		
		string st = io->readPos(pos,5);
		
		char rubish[5];
		int size;
		 
		sscanf(st.c_str(),"%d*%s",&size,rubish);

		stringstream ss;
   		ss << size;
		
		int tamanhoReal = size 
			+ (ss.str().size()+1);

		// Lê registro inteiro
		string reg = io->readPos(pos,tamanhoReal);
		
		int length;
		if(reg.find('@',0) == -1){
			int id;
			int idInd;
			int c;
			int l;
			int p;
			char d[15];
			char lc[100];
			sscanf(reg.c_str(),"%d*%d|%d|%d|%d|%d|%[^|]|%[^#|]",&length,&id,&idInd,&c,
								&l,&p,d,lc);
			if(idIndividuo == idInd){
				capturas captura(id,idInd,c,l,p,string(d),string(lc));
	
				listaDeCapturas.push_back(captura);
			}
		}


		// Atualiza pos
		pos += tamanhoReal;
		posFimArquivo -= tamanhoReal;
		
		
	}

	return listaDeCapturas;
} 
main()
{
    textbackground(BLUE);
    textcolor(WHITE);
    int matriz[n][n],op,band;
    printf("\n\t ** Matriz 4X4 **\n");
    do{
        printf("\n\n\t  --> MENU <--\n");
        printf("\n\t1. Capturar Valores\n");
        printf("\n\t2. Mostrar Valores\n");
        printf("\n\t3. Transpuesta\n");
        printf("\n\t4. Salir\n");
        printf("\n-->Elige una opcion: ");
        scanf("%d",&op);
        switch(op){
            case 1:
                band=1;
                printf("\n\t---> Captura de Datos\n");
                captura(matriz);
            break;
            case 2:
                printf("\n\t---> Mostrar Datos\n");
                if(band==1)
                    imprime(matriz);
                else
                    if(band==2)
                      imprimetrans(matriz);
                    else
                        printf("\n   \"No se han Capturado Datos\"");
            break;
            case 3:
                if(band==1)
                {
                    printf("\n\n\t---> Transpuesta de una Matriz\n");
                    transpuesta(matriz);
                }
                else
                    printf("\n   \"No se han Capturado Datos\"");
                band=2;
            break;
            case 4:
                printf("\n   \"Gracias por Utilizar el Programa\"");
            break;
            default:
                printf("\n   \"Opcion Incorrecta\"");
        }
    }while(op!=4);
    getch();
    return 0;
}
Beispiel #4
0
int main(){

    int max, cap, pos, i, j, cont;
    
    while( 1 ){
    
		scanf("%d %d", &linhas , &colunas );
		if( linhas+colunas == 0 ) return 0;
           
		n_casas = (linhas*colunas + 1)/2;
		
		i = j = 0;
		cont = 0;
		for(  pos = 1; pos <= n_casas; pos++ ){
			
			scanf("%d", &peca[i][j] );
			if( peca[i][j] == 1 ) { minha[cont][0] = i; minha[cont][1] = j; cont++; }
			j += 2;
			if( j >= colunas ) {
				i++; j = i % 2;
			}
		}
		
		max = 0;
		i = j = 0;
		for( pos = 0; pos < cont; pos++ ){
			 cap = captura( minha[pos][0], minha[pos][1] );
			 if( cap > max ) max = cap;
		}
           
		printf("%d\n", max );
           
    }
    
    return 0;
}
int main(void)
{

    int cam_mode,cam_x1,cam_y1,cam_width,cam_heigth,cam_zx,cam_zy;

    if(getSelector() == 0)
        return;

    char c;
    int i;//buff_length;
    //int wait_cam;

    //defining the position of the several inputs and outputs (motors are outputs) in the respective SFR
    //the SFR are programed as structures, so accessing to an input/output implies only acessing to the field of the structure corresponding to the SFR that was
    //assigned to that input/output (see epuck_ports.h and p30f6014.h to understand the SFR assignment)
    e_init_port();

    e_init_motors();

    //important to enable uart interface
    e_init_uart1();
    e_init_ad_scan(ALL_ADC);
    e_calibrate_ir();

    //initial configuration of the camera
    cam_x1=(ARRAY_WIDTH/Z_WIDTH-WIDTH)/2;
    cam_y1=(ARRAY_HEIGHT/Z_HEIGHT-HEIGHT)/2;
    cam_width=WIDTH;
    cam_heigth=HEIGHT;
    cam_zx=Z_WIDTH;
    cam_zy=Z_HEIGHT;
    cam_mode=MODE;

    if(cam_mode==GREY_SCALE_MODE)
            cam_size=cam_width*cam_heigth;
    else
            cam_size=cam_width*cam_heigth*2;

    //not waiting for camera
    wait_cam=0;

    e_activate_agenda(updateFlag, 500);//500//1000
    e_activate_agenda(readValues, 10);

    e_start_agendas_processing();
    keepFinding = 0;

    e_set_led(4,1);

    keepFinding = 1;

    int s = getSelector();
    while(s==getSelector());

    /*while(1){
        sprintf(b1,"%i\n",e_get_calibrated_prox(S_FRONT_LEFT));
        e_send_uart1_char(b1,10);
        while(e_uart1_sending());
    }*/

    while(1){
        while(keepFinding) {

            if(!cameraOn) {
                startCamera();
                correctRobot();
            }
            while(!captura());
            //e_send_uart1_char(buffer,buff_length);
            //while(e_uart1_sending());
            if(cameraOn > 5)
                processaImagem();
            cameraOn++;
        }

        if(cameraOn)
            stopCamera();

        while(!flag);
        flag = 0;
        sendInputs();

        readOrder();
        readOrder();

        e_set_speed_left(speedLeft);
        e_set_speed_right(speedRight);
        e_set_led(4,0);
    }

    return 0;
}
main(){
    struct ponto p;
    captura(&p);
    imprime(&p);
    getch();
}
main() {
    Ponto p;
    p = captura();
    imprime(p);
    getch();
}