// ConsoleApplication4.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
using namespace std;
struct linkNode
{
	int data;
	linkNode* next;
};
int main()
{
	linkNode* ln = new linkNode();
	ln->next = nullptr;
	for (int i = 1; i <= 10; i++)
	{
		linkNode* tmp = new linkNode();
		tmp->next = ln->next;
		tmp->data = i;
		ln->next = tmp;
		//cout << ln->data << endl;
		
	}
	linkNode* tmptmp = ln;
	for (int i = 1; i <= 10; i++)
	{
		tmptmp = tmptmp->next;
		cout << tmptmp->data << endl;
		

	}

	linkNode* tmptmp2 = ln;
	linkNode* pre = nullptr;
	while (tmptmp2 != nullptr)
	{
		linkNode* nown = tmptmp2->next;
		tmptmp2->next = pre;
		pre = tmptmp2;
		tmptmp2 = nown;
		
		//cout << tmptmp2->data;
	}
	tmptmp2 = pre;
	linkNode* tmptmp3 = tmptmp2;
	cout << "tmptmp3:";
	while (tmptmp3)
	{
		cout << tmptmp3->data << endl;
		tmptmp3 = tmptmp3->next;
	}
    std::cout << "Hello World!\n";
}
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐