📄 play.c
字号:
#include "heads_or_tails.h"
void play(int how_many) /*machine tosses,user calls */
{
int coin, i, lose=0, win=0;
for(i=0; i<how_many; i++){
coin=toss();
if(get_call_from_user()==coin){
win++;
report_a_win(coin);
}
else {
lose++;
report_a_lose(coin);
}
}
prt_final_report(win, lose, how_many);
}
void report_a_win(coin)
{
printf("the machine is: %d ",coin);
}
void report_a_lose(coin)
{
printf("the machine: %d ",coin);
}
int toss()
{
return(rand()%2); /*0=heads, 1=tails*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -