logo

Crowdly

Browser

Додати до Chrome

* Contrôles Continus - P2 - Promo 2029

Шукаєте відповіді та рішення тестів для * Contrôles Continus - P2 - Promo 2029? Перегляньте нашу велику колекцію перевірених відповідей для * Contrôles Continus - P2 - Promo 2029 в moodle.myefrei.fr.

Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!

Soit la fonction suivante, qui recherche le maximum dans une liste, de manière récursive :

int maxRecList(t_cell *cell, int cur_max)

{

if (cell == NULL) {

return cur_max;

}

if (cell->value > cur_max) {

cur_max = cell->value;

}

return maxRecList(cell->next, cur_max);

}
on souhaite appeler cette fonction depuis le programme principal, pour une liste nommée list_1, non vide.

Quel programme principal permet d'effectuer cet appel pour avoir le bon résultat ?

(on suppose que tous les bons #include sont faits)

Переглянути це питання

Soient les fonctions suivantes :

void fonction1(t_cell *ptr_c)

{

    if (ptr_c != NULL)

    {

    fonction1(ptr_c->next);

    printf("%d ", ptr_c->value);

   }

}

void fonction2(t_list mylist)

{

fonction1(mylist.head);

}

Quelle est l'affichage obtenu si on appelle la fonction2 sur la liste suivante ?

100%
0%
0%
0%
Переглянути це питання

Soient les fonctions suivantes :

void fonction1(t_cell *ptr_c)

{

    if (ptr_c != NULL)

    {

    fonction1(ptr_c->next);

    printf("%d ", ptr_c->value);

   }

}

void fonction2(t_list mylist)

{

fonction1(mylist.head);

}

Quelle est l'affichage obtenu si on appelle la fonction2 sur la liste suivante ?

0%
0%
0%
0%
Переглянути це питання

Soient les fonctions suivantes :

void fonction1(t_cell *ptr_c)

{

    if (ptr_c != NULL)

    {

    fonction1(ptr_c->next);

    printf("%d ", ptr_c->value);

   }

}

void fonction2(t_list mylist)

{

fonction1(mylist.head);

}

Quelle est l'affichage obtenu si on appelle la fonction2 sur la liste suivante ?

Переглянути це питання

Soient les fonctions suivantes :

void fonction1(t_cell *ptr_c)

{

    if (ptr_c != NULL)

    {

    fonction1(ptr_c->next);

    printf("%d ", ptr_c->value);

   }

}

void fonction2(t_list mylist)

{

fonction1(mylist.head);

}

Quelle est l'affichage obtenu si on appelle la fonction2 sur la liste suivante ?

Переглянути це питання

On souhaite 'détruire' une liste, c'est à dire libérer (free()) toutes les cellules qui la constituent

on vous propose la fonction suivante :

void destroyList(t_list *ptr_list)

{

   t_cell *cur;

   t_cell *prev;

   while (ptr_list->head !=NULL)

   {

      cur = ptr_list->head;

      prev = cur;

      while (cur->next != NULL)

      {

           prev = cur;

           cur = cur->next;

      }

      prev->next = NULL;
      if (cur == ptr_list->head)

{

ptr_list->head = NULL;

}

      free(cur);

}
}

 

Que pouvez-vous dire de cette fonction ? (plusieurs réponses)

0%
0%
0%
0%
0%
0%
Переглянути це питання

la fonction suivante effectue bien un chaînage en tête de liste (ajoute une nouvelle cellule en tête) :

(on suppose que la fonction t_cell *createCell(int); crée bien une nouvelle cellule individuelle)

void addHead(t_list mylist, int val)

{

    t_cell *new = createCell(val);

    mylist.head = new;

    new->next = mylist.head;
}

22%
78%
Переглянути це питання

En appelent la fonction suivante, on peut initialiser une liste vide dans le programme principal :

void createEmptyList(t_list mylist)

{

  mylist.head = NULL;

}

Переглянути це питання

Dans quel cas l'utilisation d'une liste chaînée simple (un seul pointeur head) est-elle plus efficace qu'un tableau ?

Переглянути це питання

Soit le programme suivant, utilisant un pointeur vers une cellule (on considère que le type t_cell est bien défini)

#include <stdio.h>

#include <stdlib.h>

#include "cell.h"

int main()

{

t_cell *ptr;

ptr = (t_cell *)malloc(sizeof(t_cell));

ptr->value = 64738;

printf("%d\n",ptr->value);

printf("%x\n", ptr->next); // affichage en hexadécimal, une valeur quelconque

printf("%d\n",ptr->next->value);

return 0;

}

Quelle sortie ne peut-on pas obtenir avec ce programme ?

Переглянути це питання

Хочете миттєвий доступ до всіх перевірених відповідей на moodle.myefrei.fr?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome