8、火柴游戏

#include<iostream>
using namespace std;
int main(){
 
  int  num=21;
  int  man; 
  while(num>=1){
      cout<<"男人取出的火柴数"; 
      cin>>man;
      if(man>=1&&man<=4){
          cout<<"女生取出"<<5-man;
      }else{
         cout<<"错误"; 
         continue;
      }
              
      num=num-5;  
  }
  
  
  system("pause"); 
}
 

我们有21根火柴,两人轮流取,一次只能够取 1-4根,不可以多取,也不可以不取,谁取到最后一根算谁输。

猜你喜欢

转载自blog.csdn.net/qq_30272539/article/details/81194354