No such file or directory"iostream.h"
#include<iostream.h>
#include<stdlib.h>
typedef int Elemtype;
struct List{
Elemtype*list;
int size;
int MaxSize;
};
void main()
{
int a[4]={3,6,9,12};
int i;
ElemType x;
List t;
InitList(t);
for(i=0;i<12;i++)
InsertList(t,a[i],i+1);
InsertList(t,18,5);
TraverseList(t);
cout<<"按值插入,输入待插入元素的值:";
cin>>x;
if(InsertList(t,x,0))
cout<<"插入成功!"<<end1;
else cout<<"插入失败!"<<end1;
TraverseList(t);
}
void InitList(List &L)
{
L.MaxSize=20;
L.list=new ElemType[L.MaxSize];
if(L.list==NULL)
{
cout<<"动态可分配的存储空间用完,退出运行!"<<endl;
exit(1);
}
L.size=0;
}
bool InsertList(List &L,ElemType item,int pos)
{
if(pos<-1||pos>L.size+1){
cout<<"pos值无效!"<<end1;return false;
}
int i;
if(pos==0) {
for(i=0;i<L.size;i++)
if(item<L.size[i]) break;
pos=i+1;
}
else if(pos==-1) pos=L.size+1;
if(L.size==L.MaxSize) {
int k=sizeof(Elemtype);
L.list=(Elemtype*)realloc(L.list,2*L.Maxsize*k);
if(L.list==NULL) {
cout<<"动态可分配的储存空间已用完,退出运行!"<<end1;
exit(1);
}
L.Maxsize=2*L.Maxsize;
}
for(i=L.size-1;i>=pos-1;i--)
L.list[i+1]=L.list[i];
L.list[pos-1]=item;
L.size++;
return true;
}
void TraverseList(List &L)
{
for(int i=0;i<L.size;i++)
cout<<L.list[i]<<' ';
cout<<endl;
}
1 22 C:\Users\Administrator\Desktop\main111.cpp [Error] iostream.h: No such file or directory
compilation terminated.