c++ 读取访问权限冲突。

arianwxz arianwxz 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
using namespace std;
typedef struct Node
{
int m_nValue;
Node *m_pNext;
}ListNode;
ListNode * creat_List() {
ListNode *pHead;
pHead = new ListNode();
pHead->m_nValue = 0;
pHead->m_nValue = NULL;
return pHead;
}
ListNode*insert_Node_behind(ListNode*pHead, int pElem) {
if (pHead = NULL) {
cout << "头结点为空" << endl;
return pHead;
}
ListNode *temp, *current;
current = pHead;
while (current->m_pNext)
{
current = current->m_pNext;
}
temp = new ListNode();
temp->m_nValue = pElem;
temp->m_pNext = NULL;
current->m_nValue += 1;
return pHead;

}
void show_List(ListNode *pHead)
{
if (pHead==NULL)
{
cout << "头结点为空" << endl;
return;
}
ListNode *temp;
temp = pHead->m_pNext;
cout << "该list为:";
while (temp!=NULL)
{
cout << temp->m_nValue << ' ';
temp = temp->m_pNext;
}
cout << endl;

}
ListNode *reverse_list_1(ListNode *pHead) {
if (pHead==NULL||NULL==pHead->m_pNext)
{
return pHead;
}
ListNode *temp, *current;
current = pHead->m_pNext;
pHead->m_pNext = NULL;
while (current!=NULL)
{
temp = current->m_pNext;
current->m_pNext = pHead->m_pNext;
pHead->m_pNext = current;
current = temp;

}
return pHead;
}
int main()
{
int n_of_list = 6;
int i = 1;
ListNode *pHead;
pHead = creat_List();
while (n_of_list>0)
{
insert_Node_behind(pHead, i++);
n_of_list;
}
show_List(pHead);
reverse_list_1(pHead);
show_List(pHead);
return 0;
}
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
arianwxz
C++ 语言 65,214 成员 250,514 内容