}
6.3.4猜字游戏 #include
int main() {
int number; int guess; char answer;
<< \< cout << \< srand ( time(0) ); guess = 1+rand( ) 00; cin >> number; { } while( (number >= 0 )&&( number <=1000 ) ) { if( number == guess ) { }; if( number > guess) { cout<<\; cout <<\< if( answer=='N' ||answer =='n' ) { } cout<< \; cin >>number; guess = 1+rand( ) 00; goto loop; break; if( answer=='y' ||answer =='Y' ) <<\; cout<<\; cin >> number; while( number >1000 ) loop: } } cin >> number; } if( number < guess) { cout<<\; cin >> number; } 6.35 #include int main() { int number; int guess; char answer; int i=0; << \< cout << \< srand ( time(0) ); guess = 1 + rand( ) 00; cin >> number; { i=0; } while( (number >= 0 )&&( number <=1000 ) ) { if( number == guess ) { if( i< 10 ) cout << \; cout << \; if( i== 10 ) if( i>10 ) cout<<\; cin >> number; while( number >1000 ) loop: } } }; cout << \; cout <<\< if( answer=='N' ||answer =='n' ) if( answer=='y' ||answer =='Y' ) { } cout<< \; cin >>number; guess = 1+rand( ) 00; goto loop; break; <<\; if( number > guess) { } if( number < guess) { } cout<<\; i++; cin >> number; cout<<\; i++; cin >> number; 6.36 #include int power( int, int ); int main() { int x; int y; } cout << \; cin >> x >> y; cout << \<< x << \<< y <<\< int power( int base, int exponent ) { } 6.37(A) #include int Fibonacci( int ); int main() { } int Fibonacci( int number ) { int numA=0, numB=0, Result=1; if ( number == 0 ) return 0; if ( number == 1 ) return Result; {for( int counter=1; counter <= number-1; counter++ ) {numA = numB; else else int x; cout << \; cin >> x ; cout << \<< x <<\<< Fibonacci( x ); if(exponent == 0 ) return 1; if( exponent == 1 ) return base; return base * power( base, exponent-1 ); else else numB = Result; Result = numA + numB; (B) 6.38 #include cout << \ void hanoi(int n,char one,char two,char three) { if(n==1) move(one,three); else { hanoi(n-1,one,three,two); move(one,three); hanoi(n-1,two,one,three); } } int main() { int m; cout<<\请?输o?入¨?盘¨?子á¨?数oy:\; cin>>m; cout<<\移°?动?¥盘¨?子á¨?的ì?步?骤¨¨为a:\< #include double distance( double,double,double,double ); { double x1,y1,x2,y2; cout<<\; cin >> x1 >> y1; int main() } } } return Result;