代碼(1)+(2)1-1完成
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int sun,r=1,x[10]={1,1,1,1,1,2,2,2,4,4};
int bobao()
{
cout<<"剩余僵尸數(shù):"<<10-r<<endl;
cout<<"僵尸血量:"<<x[r]<<endl;
cout<<"陽光數(shù):"<<sun<<endl;
cout<<"輸入數(shù)字選擇要用的植物"<<endl;
return 0;
}
int main()
{
int a;
cout<<"植物大戰(zhàn)僵尸文字版"<<endl;
cout<<"輸入“1”開始"<<endl;
cin>>a;
if(a==1)
{
cout<<"開始"<<endl;
cout<<"介紹:植物將以卡牌的形式出現(xiàn)"<<endl;
cout<<"向日葵:0陽光,產(chǎn)出1陽光"<<endl;
cout<<"豌豆:1陽光,造成1傷害"<<endl;
cout<<"初始植物:1代表使用向日葵,2代表使用豌豆"<<endl;
cout<<"1-1"<<endl;
cout<<"你的回合"<<endl;
cout<<"僵尸血量:2"<<endl;
cout<<"陽光數(shù)"<<sun<<endl;
cout<<"輸入數(shù)字選擇要用的植物"<<endl;
}
while(x[9]!=0)
{
cin>>a;?
switch(a)
{
case 1:
if(sun>=1)
{
sun--;
x[r]=x[r]-1;
if(x[r]<=0)
{
r++;
}
}
break;
case 2:
{
sun++;
}
}
bobao();
}
cout<<"1-1完成"<<endl ;
}
?//作者:沒有此號 https://www.bilibili.com/read/cv24417668?spm_id_from=333.999.0.0 出處:bilibili