Skip to content
Snippets Groups Projects
Select Git revision
  • bf848168bd6a0edfe35d6e05c87e136525b74442
  • live_exam_os_ubuntu default protected
2 results

routerVMs.go

Blame
  • alloc_mem.c 2.63 KiB
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <stdint.h>
    #include <string.h>
    #include <time.h>
    
    #include "lib_alloc.h"
    
    
    int main(){
        for (int i = 0; i != 100; i++) {
    
            srand(time(NULL));
    
            int size = nb_alea(20);
            //printf("Saisire la taille du tableau souhaitée ?\n");
            //scanf("%d", &size);
            printf("-----------------------------\n");
            
            //malloc
            int *tab = malloc(size * sizeof(int));
            int *tab_two = malloc(size * sizeof(int));
            int *tab_three = malloc(size * sizeof(int));
            int *tab_four = malloc(size * sizeof(int));
            double *tab_five = malloc(size * sizeof(int));
    
            //int count = 0;
            
            //Etape 2 : remplis tab
            fill_tab(tab, size);
    
            //Etape 3 : Print tab
            print_tab(tab, size);
            printf("-----------------------------\n");
    
            //Etapes 4 : Permu aleatoire
            permu_alea(tab, size);
            printf("-----------------------------\n");
    
            //Etapes 5 : Permu Cyclique
            int deca = nb_alea(20);
            //printf("Entre le decalage souhaité\n");
            //scanf("%d", &deca);
            printf("-----------------------------\n");
    
            permu_cyclique(tab, size, deca);
            printf("-----------------------------\n");
    
            //Etape 6 : minimum to last position  
            min_to_last(tab, size);
            printf("-----------------------------\n");
    
            //Etape 7 : max to min with insertion
            max_to_min(tab, size);
            printf("-----------------------------\n");
    
            //Etape 8 : count nb user input
            int nb_counter = nb_alea(20);
            //printf("Entrez nombre pour chercher compter plus petit.");
            //scanf("%d", &nb_counter);
            nb_count(tab, size, nb_counter);
            printf("-----------------------------\n");
    
            //Etape 9 : second malloc  -> tab + tab 2 = tab 3
            fill_tab(tab_two, size); // remplir tab 2 comme tab1
            //print_tab(tab_two, size); poru check 
            sum(tab, tab_two, tab_three, size);
            printf("-----------------------------\n");
    
            //Etape 10 : tab four fill multi with n
            int n = nb_alea(20);
            //printf("Saisir le nombre multiplicateur.\n");
            //scanf("%d", &n);
            multi_element(tab_three, tab_four, size, n);
            printf("-----------------------------\n");
    
            //Etape 11 : tab to double 
    
            tab_double(tab_four, tab_five, size);
            printf("-----------------------------\n");
            
            //liberation tableau
            free(tab);
            free(tab_two);
            free(tab_three);
            free(tab_four);
            free(tab_five);
        }
    
        return EXIT_SUCCESS;
    }