?? head.h
字號:
/*========================head.h===================================*/
/*--------頭文件,宏定義,函數申明------------*/
#include"stdio.h"
#include"stdlib.h"
#include"math.h"
#include"conio.h"
#include"time.h"
#include"graphics.h"
#define upkey 72 /*------上方向鍵-------*/
#define downkey 80 /*------下方向鍵-------*/
#define leftkey 75 /*------左方向鍵-------*/
#define rightkey 77 /*------右方向鍵-------*/
#define Enter 13 /*------回車鍵---------*/
#define ESC 27 /*------ESC鍵----------*/
#define WinColor LIGHTBLUE /*------進入界面背景色-*/
#define TitleColor BLACK /*------標題顏色-------*/
#define TextColor LIGHTGRAY /*------文本顏色-------*/
#define ChoiceColor WHITE /*------選項顏色-------*/
#define DisplayColor BLACK /*------演示界面背景色-*/
#define StarColor WHITE /*------星空顏色-------*/
#define TankColor WHITE /*------坦克顏色-------*/
#define GunColor RED /*------炮頭顏色-------*/
#define LockColor RED /*------鎖定顏色-------*/
#define WinLeft 22 /*------進入界面窗口左坐標-------*/
#define WinTop 3 /*------進入界面窗口頂坐標-------*/
#define WinRight 50 /*------進入界面窗口右坐標-------*/
#define WinBottom 12 /*------進入界面窗口底坐標-------*/
#define EnterX 10 /*------選項Enter坐標----*/
#define EnterY 5
#define ExitX 10 /*------選項EXIT坐標-----*/
#define ExitY 7
#define mMax 10 /*------最大目標數-----*/
#define nMax 10 /*------最多指標數-----*/
int n=6,m=3; /*目標數初始定為六個,目標指標定為3個*/
int best=0; /*最優目標在目標數組中的下標值*/
float f[mMax][nMax],H[nMax],Omiga[nMax]; /*----Omiga[i]為熵權-------*/
float r[mMax][nMax]; /*-----判斷矩陣------------*/
float A[mMax][nMax]; /*--加熵權的標準化指標矩陣-*/
float X[nMax]; /*-------理想點------------*/
/*------演示矩形框結構----*/
struct RECT{
int left,top,right,bottom;
int width,height,d;
}rect;
/*------炮臺結構---------*/
struct Emplacement{
int x,y;
int width,lenth;
int color;
}emp;
/*---------------------坦克目標屬性---------------------------*/
struct Target{
int ID; /*---坦克標識符,用以識別該目標的唯一編號----*/
int x,y; /*---坦克坐標----*/
int r,color; /*---坦克半徑和顏色--*/
float d; /*---距離----*/
int dIndex; /*---距離索引----*/
float T; /*---貼近度----*/
int TIndex; /*---貼近度索引----*/
int pIndex; /*---坦克排序索引---*/
int direction; /*---坦克當前運動方向---*/
float inva,distance,power;
/*----分別為坦克的三個指標:"侵略性"、"距炮臺距離"、"攻擊力"---*/
}Tank[nMax]; /*---定義坦克目標數組---*/
int color[3]={WHITE,YELLOW,RED}; /*---定義坦克的三種顏色值---*/
/*-----------------算法相關函數-------------------------*/
float Sigama(float a[],int L); /*求和*/
float findMax(float a[],int L); /*尋找最大值*/
float findMin(float a[],int L); /*尋找最小值*/
void Taxis(struct Target Tank[],int pNum);/*排序*/
void GetTData(); /*獲得當前各個目標的狀態,并形成指標數據*/
/*------------------算法步驟函數---------------------------*/
void FormMatrix(); /*構造初始指標判斷矩陣*/
void FormEntropyMatrix(); /*構造加熵權的標準化指標矩陣A*/
void FindPerfectPoint(); /*找出理想點X[m]*/
void CalDistance(); /*計算被評方案到理想點的距離Tank[j].d*/
void CalCloseDegree(); /*計算被評方案與理想點的貼近度Tank[j].T*/
void FindBestT(); /*根據貼近度和距離排序,找出最優目標*/
void Arithmetic(); /*依次調用算法六個步驟*/
/*------------------動畫演示函數-------------------------------*/
void InitBKGround(); /*初始進入界面*/
void Selected(int c,int x,int y); /*選項動態效果*/
void InitGraph(); /*圖形初始化*/
void DrawEagle(); /*畫大本營標志*/
void Emplacement(); /*畫炮臺*/
void ShowInt(int data,int x,int y); /*將整型轉化為字符型并顯示/
void DrawTank(struct Target T_pro,int Tcolor,int color); /*畫坦克*/
void DisplayBG(); /*演示背景*/
void InitTarget(); /*初始化目標并顯示*/
void DrawStarBG(); /*畫初始星空背景*/
void DrawShineStar(int x,int y,int i,int color); /*在坐標(x,y)處畫閃爍的星的圖案*/
void Shine(); /*星空閃爍效果*/
int IsXYValid(struct Target T,int x,int y);
/*決定當前坦克是否按當前方向值運動,或是碰到邊框而須改變方向*/
int Lock(struct Target T); /*鎖定目標的效果*/
void DrawMissile(int x,int y,int r,int color); /*畫導彈*/
void Attack(int x1,int y1,int x2,int y2,int color); /*攻擊效果*/
void Blast(int x,int y,int r,int color); /*爆炸效果*/
void ShowClear(); /*顯示目標全部清除的畫面*/
int Display(); /*動畫演示:找出當前最優目標并擊毀*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -