Please enter your bet (up to $100.00): $-20
Your bet is $100.00
Guess a number between 1 and 10: 5
Wrong! The computer chose: 2
You lose $60.00
Your new balance is $40.00
Please enter your bet (up to $40.00): $10.50
Guess a number between 1 and 10: 12
Wrong! The computer chose: 2
You lose $21.00
Your new balance is $19.00
Please enter your bet (up to $19.00): $0
Thank you for playing!
Press any key to continue . . .
Change to your
subject and name
帮我编译这个C++程序(急)
答案:3 悬赏:10 手机版
解决时间 2021-04-24 15:42
- 提问者网友:沉默菋噵
- 2021-04-23 15:22
最佳答案
- 五星知识达人网友:有你哪都是故乡
- 2021-04-23 16:05
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;
int main()
{
srand( time( 0 ) );
double bet = 100.00;
cout.setf( ios::fixed );
cout << setprecision( 2 );
do
{
int answer = rand() % 9 + 1;
int n;
double b;
cout << "Please enter your bet (up to $" < <bet << "):$";
cin >> b;
if( !int( b ) ) break;
if( b > bet || b < 0.0 ) {
b = bet;
cout << "Your bet is $" << b << endl;
}
cout << "Guess a number between 1 and 10:";
cin >> n;
if ( n == answer ) {
cout << "Correct!" << endl<< "You win $" << b << endl;
bet += b;
} else {
if( bet-(b = b/5*abs( answer-n ) ) < 0 )
b = bet;
cout << "Wrong! The computer chose: " << answer << endl;
cout << "You lose $" << b << endl;
bet -= b;
}
if ( !int( bet ) ) break;
cout << "Your new balance is $" << bet << endl;
} while( true );
cout << "Thank you for playing!" << endl;
}
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;
int main()
{
srand( time( 0 ) );
double bet = 100.00;
cout.setf( ios::fixed );
cout << setprecision( 2 );
do
{
int answer = rand() % 9 + 1;
int n;
double b;
cout << "Please enter your bet (up to $" < <bet << "):$";
cin >> b;
if( !int( b ) ) break;
if( b > bet || b < 0.0 ) {
b = bet;
cout << "Your bet is $" << b << endl;
}
cout << "Guess a number between 1 and 10:";
cin >> n;
if ( n == answer ) {
cout << "Correct!" << endl<< "You win $" << b << endl;
bet += b;
} else {
if( bet-(b = b/5*abs( answer-n ) ) < 0 )
b = bet;
cout << "Wrong! The computer chose: " << answer << endl;
cout << "You lose $" << b << endl;
bet -= b;
}
if ( !int( bet ) ) break;
cout << "Your new balance is $" << bet << endl;
} while( true );
cout << "Thank you for playing!" << endl;
}
全部回答
- 1楼网友:污到你湿
- 2021-04-23 18:14
请输入您的赌注(高达$ 100.00):$ -20 您的赌注是$ 100.00 猜一个介于1和10号:5 错误的!该计算机选择:2 你输$ 60.00 您的新的平衡$ 40.00 请输入您的赌注(高达$ 40.00):$ 10.50 猜一个介于1和10号码:12 错误的!该计算机选择:2 你输$ 21.00 您的新的平衡$ 19.00 请输入您的赌注(高达$ 19.00):$ 0 谢谢你玩! 按任意键继续。 。 。 更改为您的 主题和名称
是翻译还是编译..- -||
- 2楼网友:鸽屿
- 2021-04-23 17:35
这个可不是C++源码
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯