



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




// assume the string is s and s has been initialized vector
abe lincoln went to the white house
int count_vowels( const vector
int count_vowels( const vector
strings[i][j] == ’u’ ) ++count; return count; }
a = "abc", b = "abd" a = "cab", b = "cabbage" a = "christine", b = "christopher"
bool less_string( const string& a, constr string& b ) { unsigned int min_length = a.size(); if ( b.size() < min_length ) min_length = b.size(); while ( i < min_length ) { if ( a[i] < b[i] ) return true; else if (a[i] > b[i] ) return false; ++ i; } return a.size() < b.size(); }
void more_confused( vector
int main() { vector
more_confused( a, b ); a[0] = 7; a[1] = 9; more_confused( b, a );
void ASort( vector
// Swap with A[i] double temp = A[i]; A[i] = A[small_index]; A[small_index] = temp; } }
void array_to_vector( float a[], int n, vector
class Point { public: Point(); Point( double in_x, double in_y, double in_z ); void get( double & x, double & y, double & z ) const; void set( double x, double y, double z ); bool dominates( const Point & other ); private: double px, py, pz; };
bool dominates_v2( const Point & left, const Point & right );
Point::Point() { xp = yp = zp = 0.0; }
Point p( 1.5, 5.0, -1 ); Point q( 1.4, 5.0, -3 ); Point r( -3, 8.1, -7 );
p.dominates( q )
p.dominates( r ) r.dominates( q ) q.dominates(r)
bool Point::dominates( const Point& other ) { return xp >= other.xp && yp >= other.yp && zp >= other.zp; }
dominates_v2( p, q )
dominates_v2( p, r ) dominates_v2( r, q ) dominates_v2( q, r)
bool dominates_v2( const Point & left, const Point & right ) { double xpl, ypl, zpl; left.get( xpl, ypl, zpl ); double xpr, ypr, zpr; right.get( xpr, ypr, zpr ); return xpl >= xpr && ypl >= ypr && zpl >= zpr; }
hello now good now no hello first last second won now song xray now silly first