急!!求VB visual studio 2010编写一个简单的小游戏(类似扫雷、剪刀石头布这种简单的就好)要源码~ 50
1个回答
展开全部
//不知道你要什么效果,凑合着看吧
#include <iostream>
#include <ctime>
using namespace std;
void main()
{
srand(time(NULL));
int p1,p2;
cout<<"玩家一出:"<<endl;
switch(rand()%3)
{
case 0:
cout<<"剪刀"<<endl;
p1=0;
break;
case 1:
cout<<"石头"<<endl;
p1=1;
break;
case 2:
cout<<"布"<<endl;
p1=2;
break;
}
cout<<"玩家二出:"<<endl;
switch(rand()%3)
{
case 0:
cout<<"剪刀"<<endl;
p2=0;
break;
case 1:
cout<<"石头"<<endl;
p2=1;
break;
case 2:
cout<<"布"<<endl;
p2=2;
break;
}
if(p1==0&&p2==0)
cout<<"平局"<<endl;
else if(p1==0&&p2==1)
cout<<"玩家二赢"<<endl;
else if(p1==0&&p2==2)
cout<<"玩家一赢"<<endl;
else if(p1==1&&p2==1)
cout<<"平局"<<endl;
else if(p1==1&&p2==2)
cout<<"玩家二赢"<<endl;
else if(p1==1&&p2==0)
cout<<"玩家一赢"<<endl;
else if(p1==2&&p2==2)
cout<<"平局"<<endl;
else if(p1==2&&p2==0)
cout<<"玩家二赢"<<endl;
else if(p1==2&&p2==1)
cout<<"玩家一赢"<<endl;
}
#include <iostream>
#include <ctime>
using namespace std;
void main()
{
srand(time(NULL));
int p1,p2;
cout<<"玩家一出:"<<endl;
switch(rand()%3)
{
case 0:
cout<<"剪刀"<<endl;
p1=0;
break;
case 1:
cout<<"石头"<<endl;
p1=1;
break;
case 2:
cout<<"布"<<endl;
p1=2;
break;
}
cout<<"玩家二出:"<<endl;
switch(rand()%3)
{
case 0:
cout<<"剪刀"<<endl;
p2=0;
break;
case 1:
cout<<"石头"<<endl;
p2=1;
break;
case 2:
cout<<"布"<<endl;
p2=2;
break;
}
if(p1==0&&p2==0)
cout<<"平局"<<endl;
else if(p1==0&&p2==1)
cout<<"玩家二赢"<<endl;
else if(p1==0&&p2==2)
cout<<"玩家一赢"<<endl;
else if(p1==1&&p2==1)
cout<<"平局"<<endl;
else if(p1==1&&p2==2)
cout<<"玩家二赢"<<endl;
else if(p1==1&&p2==0)
cout<<"玩家一赢"<<endl;
else if(p1==2&&p2==2)
cout<<"平局"<<endl;
else if(p1==2&&p2==0)
cout<<"玩家二赢"<<endl;
else if(p1==2&&p2==1)
cout<<"玩家一赢"<<endl;
}
追问
这个是C语言吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询