struct student_tag{ int nVar; char *pStr; student_tag *next;};typedef struct student_tag Stu;Stu *CreateLink(int nCount){ Stu *pStu = new Stu; pStu->nVar = -9999; pStu->next = NULL; Stu *pHeader = pStu; for (int i = 0; i < nCount; i++) { pStu->next = new Stu; if (3 == i) pStu->next->nVar = 1; else pStu->next->nVar = i; pStu->next->next = NULL; pStu = pStu->next;} return pHeader;}void OutLinker(Stu *pHeader){ pHeader = pHeader->next; while (NULL != pHeader) { cout << pHeader->nVar << endl; pHeader = pHeader->next; } cout << " END";}void DeleteElement(Stu *pHeader, int nVa1){ Stu *pBefore = pHeader; pHeader = pHeader->next; while (NULL != pHeader) { if (nVa1 == pHeader->nVar) { pBefore->next = pHeader->next; delete pHeader; pHeader = NULL; pHeader = pBefore->next; } else { pBefore = pBefore->next; pHeader = pHeader->next; } }}要求实现void InsertElement(Stu *pHeader, int nVar)在链表中插入某个元素使其值为nVar{}void RevertLinker(Stu *pHeader)将链表翻转{}void ClearLinker(Stu *pHeader)清空链表{}
目前暂无任何回答
- 0 回答
- 0 关注
- 1166 浏览
添加回答
举报
0/150
提交
取消