正在加载图片...
int List: Insert( const int x, const int i)t /在链表第i个结点处插入新元素x Node p=first; int k=0; while(p !- null & ki-I {p=p→link;k++;}/找第i1个结点 if(p== null & first I = NULL)& cout <<"Invalid position for Insertation!n?: return 0 Node newnode= new Node(x, null); /创建新结点,其数据为x,指针为0int List::Insert ( const int x, const int i ) { //在链表第 i 个结点处插入新元素 x Node *p = first; int k = 0; while ( p != NULL && k< i -1 ) { p = p→link; k++; } //找第i-1个结点 if ( p == NULL && first != NULL ) { cout << “Invalid position for Insertation!\n”; return 0; } Node *newnode= new Node(x, NULL); //创建新结点,其数据为x,指针为0
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有