猫史档案馆


一个更无聊的c++计算扔几次硬币能让硬币立起来的代码

用户:EquinoxIM_退EquinoxIM_退查看:0 回复:0 评论:0 创建时间:2021-11-18T21:02:42


 

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
/*正面-篮球 
  反面-打游戏 
  立起来-学习 */ 
int main(){
	srand((unsigned) time(NULL));
	int n=rand()%100+1;
	int cnt=0;
	while (1) {	
		if (n<=48) {
			cout<<"basketball"<<endl;
		} else if (n<=96) {
			cout<<"play"<<endl;
		} else {
			cout<<"study"<<endl;
			break;
		}
		cnt++;
		n=rand()%100+1;
	}
	cout<<"一共"<<cnt+1<<"次"<<endl; 
	return 0;
} 


回复

上一页1 页 / 共 0下一页