Créer une activité
Jouer Compléter
Purpose : pass a struct to a function and return a struct variable


#include ____________________ / / for standard i / o
using ____________________ std ; / / reserve library objects for standard use

/ / declare the Point to represent a 2D point

struct Point
{
____________________ ____________________ ; / / the x coordinate
int y ; / / the y coordinate

} ;

void ____________________ ( ____________________ ) ; / / to print a point in the format of ( x , y )

Point ____________________ ( Point , ____________________ , ____________________ ) ; / / to move a point to a new location


int ____________________ ( )
{
Point pt = { 1 , 2 } ; / / the given point

/ / display the point before moving
____________________ << " Before ____________________ , ____________________ = " ;
Print ( pt ) ;
cout << endl ;

/ / move the point to ( 3 , 6 )
pt = move ( pt , 3 , 6 ) ;


/ / display the point after moving
cout << " After moving , pt = " ;
____________________ ( ____________________ ) ;
cout << ____________________ ;

/ / successfully done
return 0 ;
}

void Print ( Point p )
/ / to print a point
{
cout << " ( " << ____________________ . ____________________ << " , " << p . y << " ) " ; / / print the format of ( x , y )
}
Point move ( Point p , ____________________ ____________________ , ____________________ ____________________ )
/ / to move a point
{
/ / point temp ;

/ / temp . x = newX ;
/ / temp . y = newY ;
Point ____________________ = { newX , newY } ; / / a temporary point at a ____________________ ____________________
____________________ ____________________ ;


}