资源简介
内部排序的程序很简单 你可能也见过 但这个程序是把内部排序的程序跟一个小游戏结合起来的 界面也挺好的 自己结合一些小程序做的 基本上也没什么难点 主要是算法呵呵

代码片段和文件信息
#include
#include
#include “stdlib.h“
#include “stdio.h“
#include “dos.h“
#include “bios.h“
#include “graphics.h“
#include “math.h“
#include “time.h“
#include “ctype.h“
#define ESC 0x11b
#define ENTER 0x1c0d
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define MAXSIZE 100
#define DELAY for( count=0;count<=interval;count++){delay(count);}
#define INTERVAL 300
#define N 200
/**********定义排序全局变量************/
typedef int Keytype;
typedef struct rec{
Keytype key;
}redtype;
typedef struct{
redtype r[MAXSIZE+1];
long length;
}Sqlist;
int count;
int intetval=INTERVAL ;
int key=0;
int mode=1;
int ikey;
/**********定义贪吃蛇全局变量************/
int score=0;/*得分*/
int gamespeed=50000;/*游戏速度自己调整*/
struct Food
{
int x;/*食物的横坐标*/
int y;/*食物的纵坐标*/
int yes;/*判断是否要出现食物的变量*/
}food;/*食物的结构体*/
struct Snake
{
int x[N];
int y[N];
int node;/*蛇的节数*/
int direction;/*蛇移动方向*/
int life;/* 蛇的生命0活着1死亡*/
}snake;
/**********定义排序函数************/
bubblesort(struct rec r[]int n) /*冒泡排序*/
{
int ij;
struct rec w;
unsigned long int compare=0move=0;
for(i=1;i<=n-1;i++)
for(j=n-1;j>=i+1;j--)
{
if(r[j].key {
w=r[j];
r[j]=r[j-1];
r[j-1]=w;
move=move+3;
}
compare++;
}
printf(“bubblesort compare= %ldmove= %ld\n“comparemove);
}
selectsort(struct rec r[]int n) /*简单选择*/
{
unsigned long int compare=0move=0;
int ijk;
struct rec w;
for(i=1;i { k=i;
for(j=i+1;j { if(r[j].key>r[k].key)
{
compare++;
}
else{w=r[j];
r[j]=r[k];
r[k]=w;
move=move+3;
}
}
}
printf(“selectsort compare= %ldmove= %ld\n“comparemove);
}
int partition(struct rec r[]int lowint high)/*快速排序*/
{
int p;
r[0]=r[low];
p=r[low].key;
while(low while(low=p) --high;
r[low]=r[high];
while(low r[high]=r[low];
}
r[low]=r[0];
return low;
}
quicksort(struct rec r[]int lowint high)
{
int j;
if(low j=partition(rlowhigh);
quicksort(rlowj-1);
quicksort(rj+1high);
}
}
insertsort(struct rec r[]int n)/*直接插入*/
{
int ij;
unsigned long int compare=0move=0;
for(i=2;i<=n;i++)
{ compare++;
r[0]=r[i];
move++;
j=i-1;
while(r[0].key { r[j+1]=r[j];
j--;
move++;
++compare;
}
r[j+1]=r[0];
move++;
}
printf(“insertsort compare= %ldmove= %ld\n“comparemove);
}
sift(struct rec r[]int lint m) /*堆排序*/
{
int ij;
struct rec w;
i=l; j=2*i;
w=r[i];
while(j<=m)
{
if(j { j++;
}
if(w.key {
r[i]=r[j];
i=j;
j=2*i;
}
else j=m+1;
}
r[i]=w;
}
h
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 17349 2009-12-17 16:31 paixu.c
----------- --------- ---------- ----- ----
17349 1
相关资源
- 贪吃蛇游戏设计(汇编语言)
- 桌面图标贪吃蛇游戏
- 安卓贪吃蛇游戏开发源代码及开发文
- 内部排序算法的实现与比较
- 贪吃蛇游戏的FPGA实现课程设计报告—
- 数据结构课程设计内部排序算法比较
- 用Verilog编写的贪吃蛇游戏
- QT4.8做的五彩贪吃蛇游戏
- 12864液晶带字库+不带字库+51单片机贪
- 基于qt实现的贪吃蛇游戏
- 基于ARM STM32F429的红外遥控贪吃蛇游戏
- 九大内部排序算法打包
- STM32贪吃蛇游戏源代码
- 基于VGA显示 和 PS2键盘,用FPGA控制的
- 研究生Unity课程作业,自己做的贪吃蛇
- 基于FPGA,VGA和PS2键盘的贪吃蛇游戏更
- 基于FPGA的点阵贪吃蛇游戏的设计与实
- 贪吃蛇游戏 STM32F103ZET6
- 贪吃蛇.zip
- 51单片机的8*8点阵制作的贪吃蛇游戏
- unity贪吃蛇游戏
- 基于单片机stm32贪吃蛇游戏.zip
- Vivado贪吃蛇游戏键盘+VGA
- 基于stm32俄罗斯和贪吃蛇游戏keil源代
- 基于FPGA的贪吃蛇游戏
- unity2d实现的贪吃蛇游戏
- 基于51单片机12864液晶屏的贪吃蛇游戏
- QT贪吃蛇游戏源码,运行程序和环境库
- 数据结构课程设计-内部排序算法的性
- 数据结构课程设计内部排序算法比较
评论
共有 条评论