主题:数据结构程序设计c描述 计算机操作系统中的就绪,执行,阻塞三种状态
上面题目是我们留的作业,班里的男生都已经交上作业了,可是我却只是有了大体轮廓,编出的程序全都是错误,不知道怎么改,下面是我变得相关类型的一个程序,希望大家帮忙修改一下,谢啦
#include<iostream.h>
#include <stdio.h>
#include <malloc.h>
typedef char datatype;
typedef struct node
{datatype data;
struct node *next;
}linklist;
linklist *Setnull()
{linklist *head;
head=(linklist*)malloc(sizeof(linklist));
head->next=NULL;
/*head->data=0;/*?*/
cout<<"the list has bulit up"<<endl;
return(head);
}
void Show(linklist *head)
{
char ch;
linklist *p;
if(head==NULL)
{
cout<<"there isn't any progress!"<<endl;
return;
}
while(head!=NULL)
{
cout<<"the progress include:"<<head->data<<endl;
head=head->next;
}
}
void INSERT(linklist *head,char ch)
{
head->data=ch;
cout<<"the progress has insert it"<<endl;
}
void DELETEAFTER(linklist *head,linklist *p)
{linklist *r;
/*p=(linklist*)malloc(sizeof(linklist));*/
if(head==p)
head=Setnull();
while(head!=p)
{head=head->next;}
head->next=p->next;
free(p);
cout<<"the progress has been deleted!"<<endl;
Show(head);
}
void GET (linklist *head,char ah)
{
linklist *p;
p=head->next;
while(p!=NULL)
if(p->data!=ah)
p=p->next;
else break;
cout<<"the progress has been finded";
cout<<" now we will delete it!"<<endl;
DELETEAFTER(head,p);
}
void name()
{
cout<<"wen"<<endl;
}
void main()
{
linklist *head1;
head1=Setnull();
cout<<"now please input the progress U want to insert!"<<endl;
char ch;
ch=getchar();
INSERT(head1,ch);
Show(head1);
/*name();
cout<<"I love you!"<<endl;*/
cout<<"please input the name you want to find!"<<endl;
char ah;
ah=getchar();
GET(head1,ah);
}
Setnull(),Insert(),Show()三个函数没有什么问题,delete()和get()两个函数看上去好像也没什么问题,但是程序运行到这里就停止了,希望大家多帮忙,我学的很糟,问老师,却总抓不到他
#include<iostream.h>
#include <stdio.h>
#include <malloc.h>
typedef char datatype;
typedef struct node
{datatype data;
struct node *next;
}linklist;
linklist *Setnull()
{linklist *head;
head=(linklist*)malloc(sizeof(linklist));
head->next=NULL;
/*head->data=0;/*?*/
cout<<"the list has bulit up"<<endl;
return(head);
}
void Show(linklist *head)
{
char ch;
linklist *p;
if(head==NULL)
{
cout<<"there isn't any progress!"<<endl;
return;
}
while(head!=NULL)
{
cout<<"the progress include:"<<head->data<<endl;
head=head->next;
}
}
void INSERT(linklist *head,char ch)
{
head->data=ch;
cout<<"the progress has insert it"<<endl;
}
void DELETEAFTER(linklist *head,linklist *p)
{linklist *r;
/*p=(linklist*)malloc(sizeof(linklist));*/
if(head==p)
head=Setnull();
while(head!=p)
{head=head->next;}
head->next=p->next;
free(p);
cout<<"the progress has been deleted!"<<endl;
Show(head);
}
void GET (linklist *head,char ah)
{
linklist *p;
p=head->next;
while(p!=NULL)
if(p->data!=ah)
p=p->next;
else break;
cout<<"the progress has been finded";
cout<<" now we will delete it!"<<endl;
DELETEAFTER(head,p);
}
void name()
{
cout<<"wen"<<endl;
}
void main()
{
linklist *head1;
head1=Setnull();
cout<<"now please input the progress U want to insert!"<<endl;
char ch;
ch=getchar();
INSERT(head1,ch);
Show(head1);
/*name();
cout<<"I love you!"<<endl;*/
cout<<"please input the name you want to find!"<<endl;
char ah;
ah=getchar();
GET(head1,ah);
}
Setnull(),Insert(),Show()三个函数没有什么问题,delete()和get()两个函数看上去好像也没什么问题,但是程序运行到这里就停止了,希望大家多帮忙,我学的很糟,问老师,却总抓不到他