资源简介
linux终端上C语言程序,3个兵种 两种模式
代码片段和文件信息
#include
#include
#include
#define MAX 100
#define MIN 100
#define MONEY 10000
#define SOLDIERS 1000
struct soldier_attribute{
char name;
int move;
int hp;
int defense;
int attack;
int prize;
int attack_distanse;
int enemy_friend;
}s[2500]={{‘K‘220051520011}{‘I‘115021010011}{‘B‘110002015031}};
struct num_of_soldier{
int nk1;
int ni1;
int nb1;
int nk2;
int ni2;
int nb2;
}num;
void delay(int);
void print_menu();
void print_space();
void chushihua(struct soldier_attribute s[]struct num_of_soldier *pn);
void print_scene(struct soldier_attribute s[]int t);
void range_empty(struct soldier_attribute s[]int nint nearestint total);
int kill_once(struct soldier_attribute s[]int nint total);
int enemy_nearest(struct soldier_attribute s[]int nint total);
int soldier_numbers1(struct soldier_attribute s[]int total);
int soldier_numbers2(struct soldier_attribute s[]int total);
int distanse_under_range(struct soldier_attribute s[]int nint nearestint total);
int choise();
int mode_choise();
void soldier_choise(int n1int *pkint *piint *pb);
int main()
{
int knight_number1=0infantry_number1=0bowman_number1=0knight_number2=0infantry_number2=0bowman_number2=0;
int n;
int ijnearestdisk;
struct num_of_soldier *pn;
int soldier_number1soldier_number2;
int total;
pn=#
print_menu();
n=mode_choise();
puts(“choose soldiers“);
puts(“player 1 to choose“);
soldier_choise(n&knight_number1&infantry_number1&bowman_number1);
puts(“player 2 to choose“);
soldier_choise(n&knight_number2&infantry_number2&bowman_number2);
printf(“player 1 player 2\n“);
printf(“knight---%3d knight---%3d \n“knight_number1knight_number2);
printf(“infantry--%3d infantry--%3d \n“infantry_number1infantry_number2);
printf(“bowman---%3d bowman---%3d \n“bowman_number1bowman_number2);
num.nk1=knight_number1;
num.ni1=infantry_number1;
num.nb1=bowman_number1;
num.nk2=knight_number2;
num.ni2=infantry_number2;
num.nb2=bowman_number2;
soldier_number1=pn->nk1+pn->ni1+pn->nb1;
soldier_number2=pn->nk2+pn->ni2+pn->nb2;
total=soldier_number2+soldier_number1+240;
puts(“start the war: 1---start 2---exit“);
n=choise();
switch(n)
{
case 1:
j=0;
chushihua(spn);
printf(“\nplayer1‘s arm lef:%d player2‘s arm lef:%d\n“soldier_number1soldier_number2);
print_space();
print_scene(stotal);
while(soldier_number1>0&&soldier_number2>0)
{
for(i=0;i {
nearest=enemy_nearest(sitotal);
if(s[i].hp>0&&nearest>=0)
{
dis=distanse_under_range(sinearesttotal);
k=kill_once(sitotal);
if(dis>=0)
{
if(k>=0)
{
s[k].hp=-1;
s[k].name=‘-‘;
s[k].enemy_friend=0;
}
else
{
s[nearest].hp=s[nearest].hp-s[i].attack+s[nearest].defe
- 上一篇:编译原理实验之四元式的生成源代码c语言
- 下一篇:C++ 源代码 学生考勤管理系统
相关资源
- C++ 源代码 学生考勤管理系统
- 编译原理实验之四元式的生成源代码
- 基于C++的学生管理系统
- C++命令行实现的学生社团管理系统
- VC++和OpenGL实现八叉树分割
- C++宾馆管理系统
- 利用opencv做的垃圾检测代码
- C++经典算法100例
- C语言编写的前方交会代码
- SVR算法C++实现
- c语言课程设计 工资管理系统
- Frankot and Chellappa算法
- 实现对任意格式文件压缩 C++
- C++实现对文本(单纯文字,不是文本
- accelerated c++ 课后习题答案:原书作者提
- 字形轮廓提取显示C#源码
- 校级运动会 管理系统 c语言代码
- c++builder获取Cpu序列号代码
- C语言FFT
- 《C++面试宝典2015版》
- 使用c++实现用户登录界面
- djksrla最短路径算法C++实现
- 一个完整的C++ odbc连接数据库
- ARM2440定时器中断C语言版
- Large Scale C++ Software Design
- 电梯仿真代码MFC(绝对可以
- C语言库函数源代码大全
- VC/VC++ 动态加载Gif动画
- c语言直接读写xls文件,无需安装off
- FP-TREE算法 C++实现
评论
共有 条评论