标签:pos inf std rac 数据 class sizeof 线性 struct
{
int data[MAXN];//存数据
int length;//数据个数
} node;
void myinsert(int pos, int cnt)
{
for(int i = node.length ; i>=pos; i--)
{
node.data[i+1] = node.data[i];
}
node.data[pos]=cnt;
node.length++;
cout<<"success!"<<endl;
for(int i=1; i<=node.length; i++)
{
cout<<node.data[i]<<" ";
}
cout<<endl;
}
void mydelete(int pos)
{
for(int i=pos; i<node.length; i++)
{
node.data[i]=node.data[i+1];
}
node.length--;
cout<<"success!"<<endl;
for(int i=1; i<=node.length; i++)
{
cout<<node.data[i]<<" ";
}
cout<<endl;
}
void myquery(int pos)
{
cout<<node.data[pos]<<endl;
}
int main()
{
int num;
printf("input the length of data\n");
cin>>num;
node.length=num;
cout<<"input all the data"<<endl;
for(int i=1; i<=num; i++)
{
cin>>node.data[i];
}
int pos, cnt;
cout<<"input the postion and data of insert"<<endl;
cin>>pos>>cnt;
myinsert(pos, cnt);
cout<<"input the postion of the data you want to dalete"<<endl;
cin>>pos;
mydelete(pos);
cout<<"input the postion of the data you want to query"<<endl;
cin>>pos;
myquery(pos);
return 0;
}
标签:pos inf std rac 数据 class sizeof 线性 struct
原文地址:http://www.cnblogs.com/cynchanpin/p/6928229.html