Points with a struct
Cette page nécessite un navigateur récent (avec support SharedArrayBuffer). Veuillez mettre à jour Chrome, Edge, Firefox ou Safari vers la dernière version.
Points avec une structure
Un struct regroupe des valeurs liées en un seul type. Ici struct Point contient un x et un y. Complétez deux fonctions : make_point construit et retourne un Point, et move_point déplace un existant. Avec un pointeur vers une structure, vous accédez à ses champs avec ->, donc p->x += dx le déplace.
Difficulté 4/5 · 280 pièces + un petit bonus lors de la première réussite aujourd'hui
A struct Point with int x, y is given. Complete make_point(int x, int y) to build a Point, and move_point(struct Point *p, int dx, int dy) to shift it by (dx, dy) using ->.
Cliquez sur Exécuter pour voir le résultat ici.