int main()
{
    int m_tabla[T_H][T_V],i,j;
    int m_horizontal[N_MOV], m_vertical[N_MOV];
    
    for ( i=0; i<T_H; i++)
       for( j=0; j<T_V; j++)
           m_tabla[i][j] = 0;  
    
    m_horizontal[0] = 2;
    m_horizontal[1] = 1;
    m_horizontal[2] = -1;
    m_horizontal[3] = -2;
    m_horizontal[4] = -2;
    m_horizontal[5] = -1;
    m_horizontal[6] = 1;
    m_horizontal[7] = 2;
    
    m_vertical[0] = -1;
    m_vertical[1] = -2;
    m_vertical[2] = -2;
    m_vertical[3] = -1;
    m_vertical[4] = 1;
    m_vertical[5] = 2;
    m_vertical[6] = 2;
    m_vertical[7] = 1;
    
    recorridoDeCaballo( m_tabla, m_horizontal, m_vertical, T_V );
    
    imprimeTabla( m_tabla );
    
    system ( "pause" );
}
예제 #2
0
파일: practica8.c 프로젝트: javierkio/udg
int main() {
	inicializarGlobales();
	int opcion,continuarPrograma;

	do {
		imprimeCabecera();
		imprimerMenu();
		printf("Opcion a elegir? ");
	    scanf("%i",&opcion);
        continuarPrograma=1;
		switch (opcion){
			case 1:
				imprimeCabecera();
				eligeMes();
				break;
			case 2:
				imprimeCabecera();
				capturaIngresos();
				break;
			case 3:
				imprimeCabecera();
				capturaGastos();
				break;
			case 4:
				imprimeCabecera();
				imprimeIngresos();
				break;
			case 5:
				imprimeCabecera();
				imprimeGastos();
				break;
			case 6:
				imprimeCabecera();
				sacarIngresototal();
				gananciaBruta=sacarGbruta();
				porcentajeISR=calculadorISR(gananciaBruta);
				imprimeTabla();
				break;
			case 7:
				continuarPrograma=0;
				break;
			default:
				printf("Opcion Invalida\n");
				break;
		}
        if(continuarPrograma) {
            getchar();
            printf("\nPresiona entrar para continuar...");
            getchar();
        }
    }while(continuarPrograma);
	return 0;
}
예제 #3
0
void main(int argc, char *argv[]){
	j = fopen("ips.json","w");
	if(argc != 4){
		sprintf(json + strlen(json),"{\n\"Error\": \"Faltan o sobran argumentos\"\n}");
	    		fputs(json,j);
	    		fclose(j);
	}else{
		char ip[16];
		char clase, opcion;
		int num = atoi(argv[3]);
		char tipo[10];
		f = fopen("red.txt","w");
		sprintf(ip,"%s",argv[1]);
		opcion = argv[2][0];
		separaIP(ip);
		fprintf(f,"Dirección IP: %d.%d.%d.%d\n",IP[0],IP[1],IP[2],IP[3]);
		clase = getClase();
		if(clase == 'A' || clase == 'B' || clase == 'C'){	
			sprintf(tipo,"%s",getTipo(clase));
			fprintf(f,"Tipo: %s\n", tipo);
			getDiRed();
			getBroadcast(0);
			sprintf(json,"{\n\"Red\": \"%d.%d.%d.%d\",\n\"Clase\": \"%c\",\n\"Primer IP\": \"%d.%d.%d.%d\",\n\"Mascara\": \"%d.%d.%d.%d\",\n\"Broadcast\": \"%d.%d.%d.%d\",\n\"Ultima IP\": \"%d.%d.%d.%d\",\n\"Default Gateway\": \"%d.%d.%d.%d\"",red[0],red[1],red[2],red[3],clase,red[0],red[1],red[2],red[3]+1,mascara[0],mascara[1],mascara[2],mascara[3],broadcast[0],broadcast[1],broadcast[2],broadcast[3],broadcast[0],broadcast[1],broadcast[2],broadcast[3]-1,broadcast[0],broadcast[1],broadcast[2],broadcast[3]-1);
			imprimeTabla(clase);
		}else{
			fprintf(f,"Clase: %c\n",clase);
		}
		switch(opcion){
			case 's':
				validaNumero(bitsNecesarios(num),clase);
				fprintf(f,"Se crearán %d subredes\n",(int)pow(2,bitsNecesarios(num)));
				getSubredes(bitsNecesarios(num),clase);
				break;
			case 'h':
				num += 2;
				getHosts(bitsNecesarios(num),clase);
				break;
			case '-':
				sprintf(json+strlen(json),"\n");
				fputs(json,j);
				break;
			default:
				sprintf(json + strlen(json),"{\n\"Error\": \"Argumento inválido\"\n}");
	    			fputs(json,j);
	    			fclose(j);
				exit(0);
		}
		fclose(f);
		strcat(json,"}");
		fputs(json,j);;
		fclose(j);
	}
}