Exemplo n.º 1
0
int chequear(struct reg_expr* reg) {
	if (!buscar(reg->nombre, tabla_simb, &reg->clase)) {
		colocar(reg->nombre, tabla_simb, ID);
		return 1;
	}
	return 0;
}
Exemplo n.º 2
0
void QuickSort(int* v, int b, int t) {
    int pivote = 0;

    if(b < t) {
        pivote=colocar(v, b, t);
        QuickSort(v, b, pivote-1);
        QuickSort(v, pivote+1, t);
    }
}
Exemplo n.º 3
0
void quickSort(int array[], int b, int t)
{
     int pivote;
     if(b < t){
        pivote=colocar(array, b, t);
        quickSort(array, b, pivote-1);
        quickSort(array, pivote+1, t);
     }
}
Exemplo n.º 4
0
int main(void) {
#ifdef TESTING
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int caso = 1;
	nums[0] = 1;
	while (scanf("%d ", &n) > 0) {
		if (caso > 1) puts("");
		printf("Case %d:\n", caso++);
		memset(puestos, 0, sizeof puestos);
		colocar(1);
	}

	return 0;
}
Exemplo n.º 5
0
/* Colocar un número en la posición 'posicion', habiéndose colocado hasta ahora 'puestos' */
void colocar(int posicion) {
	int i;
	if (posicion == n) { /* Todos puestos: imprimir solución */
		for (i = 0; i < n - 1; ++i)
			printf("%d ", nums[i]);
		printf("%d\n", nums[n-1]);
	} else { /* Expandir el ensayo: colocar un número que cumpla la condición */
		for (i = 2; i <= n; ++i) {
			if (!puestos[i] && es_primo((nums[posicion-1] + i)) && (posicion < n-1 || es_primo((i + 1)))) {
				puestos[i] = 1;
				nums[posicion] = i;
				colocar(posicion + 1);
				puestos[i] = 0;
			}
		}
	}
}
Exemplo n.º 6
0
void agregarPalabrasReservadas(struct ts_entry *ts) {
	colocar("inicio", ts, INICIO);
	colocar("fin", ts, FIN);
	colocar("leer", ts, LEER);
	colocar("escribir", ts, ESCRIBIR);
}