进程交换

2019-07-14 10:41发布

#include #include using namespace std; //不加此句,string无法使用。string是定义在名字空间std中的 struct PCB //定义进程结构(PCB) { int ID; //进程ID int jj; //进程优先级 int dx; //进程大小 string jx; //进程信息 bool hs; //活动标识 }; //结构体寄存器,用于中转其内在数据 struct PCB A[5],t; void swap(Player *a,Player *b); int A_ID[5];//进程ID寄存器 void main() { /* vc6.0不给力,Player p1 = {"han",28,186};出现错误: non-aggregates cannot be initialized with initializer list */ p1.name = "han"; p1.age = 28; p1.height = 186; p2.name = "wang"; p2.age = 26; p2.height = 178; Player *pp1 = &p1; Player *pp2 = &p2; swap(pp1,pp2); cout<0].ID=1; A[0].jj=1; A[0].dx=3; A[0].hs=true; A[0].jx="123"; A[1].ID=20; A[1].dx=21; A[1].hs=true; A[1].jj=12; A[1].jx="2662ss"; A[2].ID=300; A[2].dx=123; A[2].hs=true; A[2].jj=56; A[2].jx="56122d"; } void swap(Player *a,Player *b) { Player temp; temp = *a; *a = *b; *b = temp; }