main.cpp
来自「数据结构中关于十字链表的实现」· C++ 代码 · 共 46 行
CPP
46 行
#include <iostream.h>
#include "CrossList.h"
void main()
{
int testArray[4][4]={{0,0,0,0},{0,1,0,0},{1,1,0,0},{1,0,0,1}};
CrossList a;
a.CreateCrossList(4,4,testArray);
cout<<"0 0 0 0\n"
<<"0 1 0 0\n"
<<"1 1 0 0\n"
<<"1 0 0 1\n"<<endl;
cout<<" 测试链表: \n";
cout<<endl<<"链表中非零元素个数为 :"<<a.GetDataNum()<<endl;
cout<<"--------------------------------------------------------"<<endl;
cout<<"对链表中任意元素进行操作:\n";
OLNode *t=a.GetOLNode(1,1);
cout<<"t->row: "<<t->row<<" ";
cout<<"t->column: "<<t->column<<" ";
cout<<"t->data: "<<t->data<<endl;
t=a.GetOLNode(2,1);
cout<<"t->row: "<<t->row<<" ";
cout<<"t->column: "<<t->column<<" ";
cout<<"t->data: "<<t->data<<endl;
/*t=a.GetOLNode(0,0);
cout<<"t->row: "<<t->row<<" ";
cout<<"t->column: "<<t->column<<" ";
cout<<"t->data: "<<t->data<<endl;*/
cout<<"--------------------------------------------------------"<<endl;
cout<<"打印链表:\n";
a.Print();
cout<<"--------------------------------------------------------"<<endl;
cout<<"分别在空链,链首,链中,链尾插入元素:\n";
cout<<"在链首中插入:\n";
a.InsertNode(0,0,1);
a.InsertNode(1,0,1);
a.InsertNode(2,2,1);
a.InsertNode(3,2,1);
a.Print();
cout<<"--------------------------------------------------------"<<endl;
cout<<"析构链表: \n";
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?