Example #1
0
int main()
{
 	FILE *archivo_in;
	FILE *archivo_out;
 
 	char linea_in[100];
	char linea_out[100];

        int res;
 
 	archivo_in = fopen("datos_in.txt","r");
	archivo_out = fopen("datos_out.txt","w");
 
 	if (archivo_in == NULL || archivo_out == NULL)
 		exit(1);
 
 	while (feof(archivo_in) == 0)
 	{
 		fgets(linea_in,100,archivo_in);
 		procesarText(linea_in);
                res = operacion(P1,OP,P2);
		sprintf(linea_out,"%d%c%d=%d\n",P1, OP, P2,res);
		printf("%s",linea_out);
		fputs(linea_out, archivo_out);	
 	}

        fclose(archivo_in);
	fclose(archivo_out);
	return 0;
}
/*
 * 	@DESC: 	Lee dos bytes desde el pc del tcb, efectua operacion con ambos y los guarda en registro 'a'.
 * 			Cada byte es una letra de un registro.
 * 			Busca el valor del registro.
 */
resultado_t _funcion_operacion(tcb_t* tcb, int32_t operacion(int32_t, int32_t),
	int32_t condicion(int32_t), char* nombre)
{
	char registro1, registro2;

	if (leer_registro(tcb, &registro1) == FALLO_LECTURA_DE_MEMORIA)
		return ERROR_EN_EJECUCION;

	if (leer_registro(tcb, &registro2) == FALLO_LECTURA_DE_MEMORIA)
		return ERROR_EN_EJECUCION;

	ansisop_ejecucion_instruccion6(nombre, registro1, registro2);

	int32_t valor_del_registro_1, valor_del_registro_2;

	if (obtener_valor_del_registro(tcb, registro1, &valor_del_registro_1)
		== EXCEPCION_NO_ENCONTRO_EL_REGISTRO)
		return ERROR_EN_EJECUCION;

	if (obtener_valor_del_registro(tcb, registro2, &valor_del_registro_2)
		== EXCEPCION_NO_ENCONTRO_EL_REGISTRO)
		return ERROR_EN_EJECUCION;

	if (condicion(valor_del_registro_2))
		return ERROR_EN_EJECUCION;

	actualizar_registro_a(tcb,
		operacion(valor_del_registro_1, valor_del_registro_2));

	return OK;
}
Example #3
0
int main(void) {

    int opcion;
    int numero1, numero2;
    
    do {
        printf("Operaciones del Malnacidation!\n");
        
        printf("Eliga su malnacida operacion:\n");
        
        printf("1. Suma\n"
               "2. Resta\n"
               "3. Multiplicacion\n"
               "4. Division\n"
               "5. Irse a la verga\n");
        
        scanf("%d", &opcion);
        
        if (5 == opcion) {
            printf("Nada que hacer, vamonos a la verga!!!\n");
            break; // terminar si la opcion es igual a 5
        }
        
        printf("\nDame el primer numero hijo de puta!:");
        scanf("%d", &numero1);
        printf("\nDame el segundo numero hijo de perra!:");
        scanf("%d", &numero2);
        
        operacion(numero1, numero2, opcion);
        
    } while (5 != opcion);
    
    return 0;
}
int main(int argc, char *argv[])
{
    
    float transaccion[FILA][COLUMNA];
    int opcion=1;
    
    SetConsoleTitle("Ejercicio 46(Matrices)");
    
    cargar_num_clientes(transaccion);
    inicializar_campos(transaccion);
    
    while(opcion!=3)
    {
                    opcion=mostrar_y_validar_menu();
                    
                    switch(opcion)
                    {
                                  case 1:
                                       operacion(transaccion);                  
                                       break;
                                       
                                  case 2:
                                       listar(transaccion);
                                       break;
                                  
                                  
                    }
                    
                    
                    
                    
    }
    
  
  //system("PAUSE");	
  return 0;
}
int PG::update(const char* query){
    return operacion(query);
}
int PG::borrar(const char* query){
    return operacion(query);
}
int PG::insert(const char* query){
    return operacion(query);
}