第51课 拍手游戏--2021.09.19
生活随笔
收集整理的這篇文章主要介紹了
第51课 拍手游戏--2021.09.19
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*
開始,時間0秒,每人都拍了一次,teacher 1秒 1次
nike 2秒1次
glair 4秒1次 試編寫一程序,算一算觀眾可聽到多少聲掌聲。每人都拍10次
*/
#include<iostream>
using namespace std;
int main()
{//time //count:觀眾聽到的拍手的次數 //teacher,nike, glair 拍手的次數int time, count,teacher,nike, glair;bool flag; time=0;count=1; teacher=nike=glair=0;do{flag=0;time++;//0 1 2 3 4 5 6 7 8 9 if(teacher<9){flag=1;teacher++;}//0 2 4......if(nike<9&& time%2==0){flag=1;nike++;}//0,4,8.....if( glair<9 && time%4==0){flag=1; glair++;}if(flag) count++;}while(teacher+nike+glair<9*3);cout<<count<<endl;cout<<"time="<<time<<endl;return 0;
}
?
?
?
?
?
總結
以上是生活随笔為你收集整理的第51课 拍手游戏--2021.09.19的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: NOIP2012复赛 普及组 第一题
- 下一篇: 普通背包问题-枚举算法(《算法竞赛宝典》