{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# ds05 - F Recurve)e se Maze)e s 4 = cfw s(General Lists e s...

This preview shows pages 1–16. Sign up to view the full content.

( F ( Recurve Recurve ) ) + } e + ( e ( Maze) Maze) + e + } 4 { = + } e ( ( General Lists ) General Lists )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
+ } L z ° + } { ± ² ¡ · ¨ ³ ¿ (¿ ª* , , ° @ } ± ° @ } * H y ² * , , ° @ } * { p ³ \$ ¿ 9nE ´ µ { ±± ± h \$¿ , , ° @ } * { ±± ± àÂ ° @ } ± ° @ } * { ² ¨ ´ ¿ * (¿ ª* @ } * H y ² * @ } * H y ² * @ } * ± à
° @ } * ¤ y ° * ´ ? \$ long Factorial ( long n ) { if ( n == 0 ) return 1 ; else return n * Factorial ( n- 1) ; } ° @ } * h - = = 1 , )! 1 ( 0 , 1 ! n n n n n

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
µ ~ ° n ! e
´ P ¸ a Fib ( n ) e long Fib ( long n ) { if ( n <= 1 ) return n ; else return Fib ( n - 1) + Fib ( n - 2) ; } - + - = = 1 ), 2 ( ) 1 ( 0,1 , ) ( n n Fib n Fib n n n Fib

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
° @ } * = S template <class Type> void Find ( ListNode <Type> *f ) { if ( f link == NULL ) cout << f data << endl; else Find ( f link ); } ° @ } * H
¹ ˘ a · 9 n ¤ v ° * template <class Type> void Print ( ListNode <Type> *f ) { if ( f ! = NULL ) if ( f data == x ) cout << f data << endl; else Print ( f link ); }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
° @ } * ´ º ° @ } * X ' μ ª* ( ( Tower of Hanoi Tower of Hanoi ) ) + e
#include <iostream.h> #include "strclass.h” void Hanoi ( int n , String A , String B , String C ) { // + } 4 { b if ( n == 1 ) cout << " move " << A << " to << C << endl; else { Hanoi ( n - 1, A , C , B ) ; cout << " move " << A << " to " << C << endl; Hanoi ( n - 1, B , A , C ) ; } }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
+ } »´ »´ s 1 1 ( ( ) * 2 2 2 2 + H 3 3 3 3 H 4 4 4 4 ( ( ) ( 3 3 3 3 ( ( ) ( 2 2 2 2 + H 5 5 5 5 ( ( ) ( 2 2 2 2 H 6 6 6 6 + H 7 7 ( ( ) 4 4 3 3 5 5 2 2 1 1 7 7 6 6 6 6 e 0 0 e 2 2 e 0 0 e 3 3 e 5 5 e 6 6 0 0 0 4 0 4 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 7 0 0 7 7
+} 4 ( { ° * #include <iostream.h> #include <fstream.h> #include <stdlib.h> class Maze { private: int MazeSize ; int EXIT ; Intersection *intsec ; public: Maze ( char *filename ) ; int TraverseMaze ( int CurrentPos ) ; } +} 4 2 h struct Intersection { int left ; int forward ; int right ; }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Maze :: Maze ( char *filename ) { // 2 filename = // 2 ifstream fin ; fin .open ( filename , ios::in | ios::nocreate ); // 2 H , if ( ! fin ) { cout << “ = 4 << filename << “ F << endl; exit ( 1 ); } fin >> MazeSize ; // 2 4
intsec = new Intersection [ MazeSize+ 1] ; // h for ( int i= 1 ; i<=MazeSize ; i++ ) fin >> intsec [ i ] .left >> intsec [ i ]. forward >> intsec [ i ] .right ; fin >> EXIT ; // 4 fin .close ( ) ; } +} 4 int Maze :: TraverseMaze ( int CurrentPos ) { if ( CurrentPos > 0 ) { // e 1 e

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
if ( CurrentPos == EXIT ) { // e cout << CurrentPos << " " ; return 1 ; } else // e + e e if ( TraverseMaze ( intsec [ CurrentPos ] .left )) { cout << CurrentPos << “ ; return 1 ; } else // e + e e if ( TraverseMaze ( intsec [ CurrentPos ] .forward )) { cout << CurrentPos << “ ; return 1 ; } else // e + e e if ( TraverseMaze ( intsec [ CurrentPos ] .right )) { cout << CurrentPos << " " ; return 1 ; } } return 0 ; }
+} 4 { ´ 8 b

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 52

ds05 - F Recurve)e se Maze)e s 4 = cfw s(General Lists e s...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online