跳到正文

闲话

闲话#2:体育之乒乓大战1.0

sunqihuan约 3 分钟
原文
文章信息与版本

文章信息

发布
2024年9月15日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 3 分钟

版本

  1. v1当前

和小伙伴赌赌球吧!

C++
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
/*
1.短球
2.长球
3.擦边
4.擦网
5.扣球
6.上旋
7.下旋 
*/
string c[15]={"","短球","长球","擦边","擦网","扣球","上旋","下旋"};
int t; 
void f(bool now,int last){
	int r=0;
	if(last==-1){
		r=rand()%7+1;
		if(r==4){
			cout<<"发球擦网,换方重发!\n";
			Sleep(t);
			f(now==0?1:0,-1);
		}
		if(now==true)cout<<"红方打出";
		else cout<<"蓝方打出"; 
		cout<<c[r]<<endl;
		Sleep(t);
		f(now==0?1:0,r);
	} 
//	if(last==1){
		r=rand()%20;
		if(r==2){
			cout<<"哎呀!";
			if(now==true)cout<<"红方";
			else cout<<"蓝方"; 	
			cout<<"没有接到";
			if(now==0?1:0==true)cout<<"红方";
			else cout<<"蓝方"; 	
			cout<<"打出来的"<<c[last]<<endl;
			Sleep(t);
			if(now==0?1:0==true)cout<<"红方";
			else cout<<"蓝方"; 	
			cout<<"获胜!!!\n";
			exit(0);							 
		}else{
			/*
			if(now==true)cout<<"红方";
			else cout<<"蓝方";			
			cout<<"向前够!\n";
			Sleep(t);
			*/
			if(now==true)cout<<"红方";
			else cout<<"蓝方";	
			cout<<"接到了";
			if(now==0?1:0==true)cout<<"红方";
			else cout<<"蓝方";	
			cout<<"打出来的"<<c[last]<<endl;
			Sleep(t);
			cout<<"漂亮!";
			if(now==true)cout<<"红方";
			else cout<<"蓝方";
			cout<<"以一个";
			r=rand()%7+1;
			cout<<c[r]<<"回敬";
			if(now==0?1:0==true)cout<<"红方";
			else cout<<"蓝方";	
			cout<<endl;
			Sleep(t);
			f(now==0?1:0,r);							
		}
//	}
}
int main(){
	cin>>t;
	system("cls");
	srand(time(0));
	f(1,-1);
	return 0;
}

原文