Exemplo n.º 1
0
void ex02() {
	
	int status ;
	
	int * vet ;
	int tamVet ;
	
	printf("Antes do fork\n") ;
	
	printf("Gera Vetor\n") ;
	vet = geraVetor(&tamVet, vet);
	
	printf("Exibe Vetor\n") ;
	exibeVetor(vet, tamVet) ;
	
	printf("Fork\n") ;
	if(fork() != 0) { // parent code
		
		waitpid(-1, &status, 0);
		
		printf("Pai Exibe\n") ;
		exibeVetor(vet, tamVet) ;
		
	} // fim do if
	
	else { // child code
		printf("Filho Exibe\n") ;
		exibeVetor(vet, tamVet) ;
		
		printf("Filho Ordena\n") ;
		ordenaVetor(vet, tamVet) ;
		
		printf("Filho Exibe\n") ;
		exibeVetor(vet, tamVet) ;
		
	} // fim do else
	
} // fim do ex02
Exemplo n.º 2
0
int main()
{
    int tamanhoVetor, contador=0;
    int vetor[tamanhoVetor];
    printf("Digite o tamanho da lista: ");
    scanf("%d", &tamanhoVetor);
    fflush(stdin);

    if(tamanhoVetor <= 100)
    {
        int i;
        for(i=0; i<tamanhoVetor; ++i)
        {
            printf("Digite o valor da lista[%d] ", i+1);
            scanf("%d", &vetor[i]);
            fflush(stdin);

            if(vetor[i] < 256)
            {
                contador++;
            }
            else { /*Aqui os numeros maiores ou iguais a 256 sao ignorados*/ }
        }

        ordemDecrescente(vetor, tamanhoVetor);
        exibeVetor(vetor, tamanhoVetor);
        calculaExibeQuantidadePar(vetor, tamanhoVetor);
        calculaExibeQuantidadeImpar(vetor, tamanhoVetor);
        mediaNumerosImparesMaioresCinquenta(vetor, tamanhoVetor);
    }
    else
    {
        printf("Tamanho nao permitido\nA lista tem no maximo 100 numeros inteiros\n");
    }

    return 0;
}