好文档 - 专业文书写作范文服务资料分享网站

C++大学教程习题解答(第七版) 

天下 分享 时间: 加入收藏 我要投稿 点赞

}

cout<<\; cin >> x2 >> y2;

cout<<\; cout << distance( x1,y1,x2,y2 ) ;

double distance( double x1value ,double y1value ,double x2value,double y2value ) { return sqrt( pow( x1value - x2value ,2 ) + pow( y1value - y2value ,2 ) );

} 6.49

#include #include #include using namespace std;

int rollDice(); int Pointmake(); int main() { enum Status{ CONTINUE, WON, LOST }; int myPoint; Status gameStatus; int bankBalance = 1000; int wager;

cout << \ cin >> wager;

while( wager <= bankBalance ) {

srand( time( 0 ));

int sumOfDice = rollDice(); switch( sumOfDice ) { case 7: case 11: gameStatus = WON;

break;

case 2: case 3: case 12:

gameStatus = LOST;

; } }

}

break;

gameStatus = CONTINUE; myPoint = sumOfDice;

cout<<\<

default:

while( gameStatus == CONTINUE ) { }

if( gameStatus == WON ) } else { }

cout<<\<

cout <<\<

cout<<\<

cout <<\<

cout <<\<

gameStatus = WON; if( sumOfDice ==7 ) gameStatus = LOST; else

if ( bankBalance ==0 )cout<<\;

int rollDice() {

int sum = die1 +die2;

cout<<\<

}

return sum;

6.50

#include #include using namespace std;

const double PI = 3.1415926;

inline double circleArea( double radius) { }

int main() { } 6.51

#include using namespace std;

int tripleByValue( int );

void tripleByReference( int & );

int main() { }

int tripleByValue( int number) {

return number *3;

cout <<\ <

cout << \; cin >> count; double R;

cout <<\; cin >> R;

cout << \<

}

void tripleByReference( int &numberRef ) { numberRef= numberRef *3;

} 6.53

#include #include\ using namespace std;

int main( ) { int int1,int2;

cout << \; cin >> int1 >>int2;

cout << \<

cout << \; cin >> double1 >>double2;

cout << \<

char char1,char2;

cout << \; cin >> char1 >>char2;

cout << \<

template

T minimum( T value1, T value2 ) { T minimunValue = ( value1 < value2 ) ? value1 :value2 ; return minimunValue; } 6.54

#include #include\ using namespace std;

int main( ) {

int int1,int2;

}

cout << \; cin >> int1 >>int2;

cout << \<

cout << \; cin >> double1 >>double2;

cout << \<

char char1,char2;

cout << \; cin >> char1 >>char2;

cout << \<

头文件

template

T maximum( T value1, T value2 ) { } 6.56

#include #include #include #include #include using namespace std;

void NewQuestion(int&,int&); //int Resultvalue( );

int main( ) {

int num1;

cout << setw( 10 ) <<\<

NewQuestion(num1,num2); cin>> Result;

while ( Result != num1* num2 )

cout << \<

int num2;

T maximumValue = ( value1 > value2 ) ? value1 :value2 ; return maximumValue;

loop:

8lwww86r4o862m61dk4v721et5ixox005np
领取福利

微信扫码领取福利

微信扫码分享