哪种储存管理方式可以加载比内存大的程序

哪种储存管理方式可以加载比内存大的程序,第1张

连续分配存储管理方式

连续分配存储管理方式。连续分配存储存储管理方式可以加载比内存大的程序。存储管理是 *** 作系统的重要组成部分,它负责计算机系统内存空间的管理。其目的是充分利用内存空间,为多道程序并发执行提供存储基础,并尽可能地方便用户使用。

# include "iostream"

# include "String.h"

using namespace std

struct List

{

char name[20]

int NO

}

template <class List>

struct Node

{

List data

Node<List>*next

}

template <class List>

class Student

{

Node<List>*head

public:

Student(int m)

void Setdata(int n)

void PrintStudent()

int Get(char b[])

void Delete(int i)

void Insert(int i,List item)

void Change(char a[],int num)

~Student()

}

template <class List>

Student<List>::Student(int m)

{

Node<List>*r,*s

head = new Node<List>

r = head

for (int i = 0i <mi++)

{

s = new Node<List>

r->next = s

r = s

}

r->next = NULL

}

template <class List>

void Student<List>::Setdata(int n)

{

Node<List>*p

p = head->next

for(int i = 0i <ni++)

{

cout<<"请输入姓名:"

cin>>p->data.name

cout<<"请输入身份z号码:"

cin>>p->data.NO

p = p->next

}

}

template <class List>

void Student<List>::PrintStudent()

{

Node<List>*p

p = head->next

while (p)

{

cout<<p->data.name<<","<<p->data.NO<<endl

p = p->next

}

}

template <class List>

int Student<List>::Get(char b[])

{

Node<List>*p

p = head->next

while(p &&strcmp(p->data.name,b) != 0)

{

p = p->next

}

return p->data.NO

}

template <class List>

void Student<List>::Delete(int i)

{

Node<List>*p,*q

p = head

int j = 0

while(p &&j <i-1)

{

p = p->next

j++

}

if(!p || !p->next) {cerr<<"删除位置非法"exit(1)}

else

{

List x

q = p->next

x = q->data

p->next = q->next

delete q

cout<<x.name<<","<<x.NO<<endl

}

}

template <class List>

void Student<List>::Insert(int i,List item)

{

Node<List>*p,*s

p = head

int j = 0

while (p &&j <i-1)

{

p = p->next

j++

}

if(!p) {cerr<<"插入位置非法"exit(1)}

else

{

s = new Node<List>

strcpy(s->data.name,item.name)

s->data.NO = item.NO

s->next = p->next

p->next = s

}

}

template <class List>

void Student<List>::Change(char a[],int num)

{

Node<List>*p

p = head->next

while (p &&strcmp(p->data.name,a) != 0)

{

p = p->next

}

p->data.NO = num

}

template <class List>

Student<List>::~Student()

{

Node<List>*p,*q

p = head

while (p)

{

q = p

p = p->next

delete q

}

head = NULL

}

void main()

{

cout<<"请建立学籍系统"<<endl

int m

cout<<"请输入总人数:"

cin>>m

Student<List>stu(m)

int n = m

stu.Setdata(n)

stu.PrintStudent()

int choice

do

{

cout<<"********"<<endl

cout<<"1.查询"<<endl

cout<<"2.删除"<<endl

cout<<"3.插入"<<endl

cout<<"4.修改"<<endl

cout<<"0.退出"<<endl

cout<<"********"<<endl

cout<<"请输入您的选择:"

cin>>choice

switch(choice)

{

case 1:

{

char b[20]

cout<<"请输入需查询的姓名:"

cin>>b

cout<<"查询人的学号为:"

cout<<stu.Get(b)<<endl

}break

case 2:

{

int i

cout<<"请输入需删除数据的位置:"

cin>>i

cout<<"删除的数据为:"

stu.Delete(i)

}break

case 3:

{

List item

cout<<"请输入需插入学生的姓名:"

cin>>item.name

cout<<"请输入需插入学生的学号:"

cin>>item.NO

int i

cout<<"请输入需插入的位置:"

cin>>i

stu.Insert(i,item)

stu.PrintStudent()

}break

case 4:

{

char a[20]

cout<<"请输入需修改人的姓名:"

cin>>a

int num

cout<<"请输入修改的新学号:"

cin>>num

stu.Change(a,num)

stu.PrintStudent()

}break

case 0:

{

exit(1)

}break

default:

{

cout<<"选择项非法,请重新选择"

cout<<endl

cout<<endl

}

}

} while(choice)

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8130270.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存