#include<bits/stdc++.h>
using namespace std;
struct hero {
char name[20];
}hero[6];//英雄名字
// srand(time(0)),[m,n]->rand%(n-m+1)+m;//随机数生成范围书写通式
struct action {
char act[20];
}action[20];//技能
struct result{
char jg[8];
}result[6];//比赛胜负结果
int flaghero[100]={0};
int act[100]={0}; //英雄、技能去重
int score1=0;
int score2=0;//统计得分
int pd;
int main(){
strcpy(hero[0].name,“盖伦”);
strcpy(hero[1].name,“提莫”);
strcpy(hero[2].name,“剑圣”);
strcpy(hero[3].name,“锐雯”);
strcpy(hero[4].name,“剑姬”);
strcpy(hero[5].name,“亚索”);
strcpy(action[0].act,“放了个屁给”);
strcpy(action[1].act,“拿了把大刀砍向”);
strcpy(action[2].act,“怒目狰狞地盯着”);
strcpy(action[3].act,“大声吼向”);
strcpy(action[4].act,“打了个大嗝给”);
strcpy(action[5].act,“用小拳拳捶向”);
strcpy(result[0].jg,“战胜了”);
strcpy(result[1].jg,“输给了”);
strcpy(result[2].jg,“险胜了”);
strcpy(result[3].jg,“惨败给”);
strcpy(result[4].jg,“完胜了”);
strcpy(result[5].jg,“惜败给”);
while(pd!=1){
srand(time(0));
int a = rand()%(5-0+1)+0;
int b = rand()%(5-0+1)+0;
int c = rand()%(5-0+1)+0;
int d = rand()%(5-0+1)+0;
int e = rand()%(5-0+1)+0;
if(c%2==0)score1++;
else score2++;
flaghero[a]=1;
while(flaghero[b])
{
b = rand()%(5-0+1)+0;
}
flaghero[a]=0;//英雄去重
act[d]=1;
while(act[e])
{
e = rand()%(5-0+1)+0;
}
act[d]=0;//技能去重
printf(“开始游戏”);
getchar();
printf(“1号玩家选择角色:”);
getchar();
printf("%s",hero[a].name);
getchar();
printf(“2号玩家选择角色:”);
getchar();
printf("%s",hero[b].name);
getchar();
printf(“开始决斗”);
getchar();
printf("%s%s%s",hero[a].name,action[d].act,hero[b].name);
getchar();
printf("%s%s%s",hero[b].name,action[e].act,hero[a].name);
getchar();
以上是用c语言书写的一个简易的双人游戏,其中英雄选择、技能、胜负都是随机的。
如何进行游戏?编译运行完,疯狂按回车就好了
界面时这样的
非常简陋哈哈哈哈哈
如果把英雄改成某种特定的xx,再把技能改成特定的xx,在特地的情况下,应该是会有些许乐趣,哈哈哈哈