早教吧作业答案频道 -->其他-->
帮忙写个C++的Code,是英语题.Writeaprogramthatsimulatescointossing.Foreachtossofthecoin,theprogramshouldprintHeadsorTails.Lettheprogramtossthecoin100timesandcountthenumberoftimeseachsideofthecoinappears.P
题目详情
帮忙写个C++的Code,是英语题.
Write a program that simulates coin tossing. For each toss of the coin, the program should print Heads or Tails. Let the program toss the coin 100 times and count the numberof times each side of the coin appears. Print the results. The program should call a separate function flip that takes no arguments and returns 0 for tails and 1 for heads. [Note: If the program realistically simulates the coin tossing, then each side of the coin should appear approximately half the time.]
写一个程序,模拟掷硬币.对于每一个硬币的折腾,程序应该打印头或尾.让程序抛硬币100次计数numberof次出现每个硬币的一面.打印结果.该程序应调用不带任何参数,并返回0的尾巴和1头一个单独的函数翻转. [注意:如果该程序切实模拟掷硬币,那么每个硬币的一面应出现约一半的时间.
这个是工具翻译的,大概这个意思,高手帮忙写个code啊~~~谢谢
Write a program that simulates coin tossing. For each toss of the coin, the program should print Heads or Tails. Let the program toss the coin 100 times and count the numberof times each side of the coin appears. Print the results. The program should call a separate function flip that takes no arguments and returns 0 for tails and 1 for heads. [Note: If the program realistically simulates the coin tossing, then each side of the coin should appear approximately half the time.]
写一个程序,模拟掷硬币.对于每一个硬币的折腾,程序应该打印头或尾.让程序抛硬币100次计数numberof次出现每个硬币的一面.打印结果.该程序应调用不带任何参数,并返回0的尾巴和1头一个单独的函数翻转. [注意:如果该程序切实模拟掷硬币,那么每个硬币的一面应出现约一半的时间.
这个是工具翻译的,大概这个意思,高手帮忙写个code啊~~~谢谢
▼优质解答
答案和解析
#include
#include
using namespace std;
int f();
int main()
{
srand((unsigned)time(0));
int heads=0,tails=0;
for(int i=0;i
#include
using namespace std;
int f();
int main()
{
srand((unsigned)time(0));
int heads=0,tails=0;
for(int i=0;i
看了 帮忙写个C++的Code,是...的网友还看了以下:
我上初二刚学习压强,就在这个液体压强上有点搞不明白,我知道P=p(rou)gh可是我一碰见应用题就 2020-05-13 …
如果命题“p且q”与命题“p或q”都是假命题,那么()A.命题“非p”与命题“非q”的真值不同B. 2020-05-23 …
复合命题非P如果一个复合命题p是真,那非p一定是假如果一个简单命题p是真,那非p不一定是假.我这样 2020-07-29 …
如果命题“p且q”与命题“p或q”都是假命题,那么()A.命题“非p”与命题“非q”的真值不同B. 2020-08-01 …
对于命题p和命题q,若p真q假,则命题p∧q和命题p∨q的真假为()A.p∧q和p∨q都为真B.p∧ 2020-12-13 …
根据下列各组命题中的p,q写出命题p∧q、p∨q、¬p并判断起真假.根据下列各组命题中的p,q写出命 2020-12-13 …
对于下述命题p,写出“¬p”形式的命题,并判断“p”与“¬p”的真假:(1)p:91∈(A∩B)(其 2020-12-13 …
对于下述命题p,写出“¬p”形式的命题,并判断“p”与“¬p”的真假:(1)p:91∈(A∩B)(其 2020-12-13 …
如果命题“p或q”为真,命题“p且q”为假,则()A.命题p和命题q都是假命题B.命题p和命题q都是 2020-12-31 …
如果命题“P或q”为真命题,命题“P且q”为假命题,那么()A.命题P和q都是为真命题B.命题P和q 2021-01-01 …