#include //实现进程的优先级调度算法 #include
#include
#define MAXSIZE 100
typedef struct
{
int id; //进程ID
int key; //进程的优先级
}xinxiType;
typedef struct//这是定义一组数组进程
{
xinxiType r[MAXSIZE];
int length; //定义进程数
}Sqlist;
typedef Sqlist HeapType;
void Intial(HeapType *H)//初始化进程
{
int i;
for(i=0;i
{
H->r[i].id=0;
H->r[i].key=0;
H->length=0;
}
}
void CreatHeap(HeapType *H,int a,int b) {
H->length++;
H->r[H->length].id=a;
H->r[H->length].key=b;
}
void BubbleSort(int n,int a[2][6])
{
int i,j;
for(j=0;j
{
for(i=0;i
{
if(a[1][i]>a[1][i+1])
{
int m; //新建一个数组元素
m=a[1][i];
a[1][i]=a[1][i+1];
a[1][i+1]=m;
int p;
p=a[0][i];
a[0][i]=a[0][i+1];
a[0][i+1]=p;
}
}
}
cout
{
cout}
void main()
{
int x=0,y=0,i;
HeapType *H;
H=(HeapType *)malloc(sizeof(HeapType)); Intial(H);
cout
{
cin>>x>>y;
cout
if(x==-1)
break;
CreatHeap(H,x,y);
}
int v=H->length+1;
int a[2][6];
for(i=0;i
{ a[0][i]=H->r[i].id;
a[1][i]=H->r[i].key;
}
BubbleSort(5,a);
}
"
#include //实现进程的优先级调度算法 #include
#include
#define MAXSIZE 100
typedef struct
{
int id; //进程ID
int key; //进程的优先级
}xinxiType;
typedef struct//这是定义一组数组进程
{
xinxiType r[MAXSIZE];
int length; //定义进程数
}Sqlist;
typedef Sqlist HeapType;
void Intial(HeapType *H)//初始化进程
{
int i;
for(i=0;i
{
H->r[i].id=0;
H->r[i].key=0;
H->length=0;
}
}
void CreatHeap(HeapType *H,int a,int b) {
H->length++;
H->r[H->length].id=a;
H->r[H->length].key=b;
}
void BubbleSort(int n,int a[2][6])
{
int i,j;
for(j=0;j
{
for(i=0;i
{
if(a[1][i]>a[1][i+1])
{
int m; //新建一个数组元素
m=a[1][i];
a[1][i]=a[1][i+1];
a[1][i+1]=m;
int p;
p=a[0][i];
a[0][i]=a[0][i+1];
a[0][i+1]=p;
}
}
}
cout
{
cout}
void main()
{
int x=0,y=0,i;
HeapType *H;
H=(HeapType *)malloc(sizeof(HeapType)); Intial(H);
cout
{
cin>>x>>y;
cout
if(x==-1)
break;
CreatHeap(H,x,y);
}
int v=H->length+1;
int a[2][6];
for(i=0;i
{ a[0][i]=H->r[i].id;
a[1][i]=H->r[i].key;
}
BubbleSort(5,a);
}
"