Icon Créer jeu Créer jeu

Practice Programming

Compléter

Practice Programs

Téléchargez la version pour jouer sur papier

Âge recommandé: 17 ans
6 fois fait

Créé par

United States

Top 10 résultats

  1. 1
    01:48
    temps
    100
    but
Voulez-vous apparaître dans le Top 10 de ce jeu? pour vous identifier.
Créez votre propre jeu gratuite à partir de notre créateur de jeu
Affrontez vos amis pour voir qui obtient le meilleur score dans ce jeu

Top Jeux

  1. temps
    but
  1. temps
    but
temps
but
temps
but
 
game-icon

Compléter

Practice ProgrammingVersion en ligne

Practice Programs

par Liz Smith
1

endl newX int return namespace int int Point temp temp Print newY x pt Print move iostream new pt x cout p main int int moving location

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
;


}

educaplay suscripción