int get_coins( int * pcents, int coin ) { int number_of_coins = 0; if( * pcents > coin ) { number_of_coins = * pcents / coin; *pcents -= number_of_coins * coin; } return number_of_coins; }
int quarters = get_coins( & cents, 25 ); int dimes = get_coins( & cents, 10 ); int nickels = get_coins( & cents, 5 );
struct Triangle { Vertex v1; Vertex v2; Vertex v3; };
double distanceToTriangle( const Vertex & pt, const Triangle & triangle ) { Vertex u = triangle.v2 - triangle.v1; Vertex v = triangle.v3 - triangle.v1; Vertex w = point - Triangle.v1; // and so on
using pairstrstr = std::pair< std::string, std::string >; using vpairstrstr = std::vector< pairstrstr >; using uosetstr = std::unordered_set< std::string >;
bool ViolatesConstraints( std::string item1, std::string item2, const vpairstrstr & constraints ); void FindRequiredItems( std::string item, const vpairstrstr & inclusions, uosetstr & requiredItems );
cin >> index; Shape * pobj = Shape::CreateShapeObject( int index ); pobj->PromptAndCompute(); delete pobj;
if( n == 5 ) { Sphere obj; obj.PromptAndCompute(); }