ds05 - ■ ❀ F Recurve Recurve e ■ e Maze Maze e ■ 4...

Info iconThis preview shows pages 1–15. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ■ ❀ ( F ( Recurve Recurve ) ) + } e ■ + ( e ( Maze) Maze) + e ■ + } 4 { = ■ + } e ( ( General Lists ) General Lists ) + } Lz&¶“ ■ + } { ¡¢£· ‚¨¤¿ ♥ (¿ ª* , , & @ } ¡ & @ } * 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 ( , 1 ! n n n n n &~¡¶ 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 ° @ } * = S template <class Type> void Find ( ListNode <Type> *f ) { if ( f → link == NULL ) cout << f → data << endl; else Find ( f → link ); } ° @ } * H &˘a·“*¡ —9nE¡ ¤v¢¶“* template <class Type> void Print ( ListNode <Type> *f ) { if ( f ! = NULL ) if ( f → data == x ) cout << f → data << endl; else Print ( f → link ); } ° @ } * & ¡ ° @ } * 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 ) ; } } + } &¡ &¡ 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 e 2 2 e e 3 3 e 5 5 e 6 6 0 4 0 4 0 0 0 0 7 0 7 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 ; } 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 if ( CurrentPos == EXIT ) { // e cout << CurrentPos << " " ; return 1 ; } else // e + e e if ( TraverseMaze ( intsec [ CurrentPos ] .left )) { cout << CurrentPos << “...
View Full Document

Page1 / 52

ds05 - ■ ❀ F Recurve Recurve e ■ e Maze Maze e ■ 4...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online