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

arianwxz 2017-03-02 09:14:07
#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;
}
...全文
704 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
幻夢之葉 2017-03-03
  • 打赏
  • 举报
回复
ListNode * creat_List() { ListNode *pHead; pHead = new ListNode(); pHead->m_nValue = 0; //pHead->m_nValue = NULL; pHead->m_pNext = NULL; return pHead; }
赵4老师 2017-03-03
  • 打赏
  • 举报
回复
崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack即“调用堆栈”里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处,看不懂时双击下一行,直到能看懂为止
小灸舞 2017-03-03
  • 打赏
  • 举报
回复 1
代码功能归根结底不是别人帮自己看或讲解或注释出来的;而是被自己静下心来花足够长的时间和精力亲自动手单步或设断点或对执行到某步获得的中间结果显示或写到日志文件中一步一步分析出来的。
提醒:再牛×的老师也无法代替学生自己领悟和上厕所!
单步调试和设断点调试(VS IDE中编译连接通过以后,按F10或F11键单步执行,按Shift+F11退出当前函数;在某行按F9设断点后按F5执行停在该断点处。)是程序员必须掌握的技能之一。

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧