懂C语言进,帮弄个简单程序

来源:百度知道 编辑:UC知道 时间:2024/06/09 05:03:37
编程创建一个静态链表,该链表中的节点分别储存你的家庭成员、朋友、同学的信息.

对于你具体的要求不是很明白,我这里只帮你实现一个框架,具体信息自己填充就可以了

#include <malloc.h>

typedef struct _TPersonInfo
{
char m_szType[256];
//...这里添加自己需要包含的信息
} TPersonInfo;

typedef struct _TPerson
{
TPersonInfo m_Mather;
TPersonInfo m_Father;
TPersonInfo m_ClassMate; //可以定义为数组
TPersonInfo m_Colleague; //可以定义为数组
}TPerson;

typedef struct _TDataNode
{
_TDataNode* m_pNext;
char* m_pData;
}TDataNode;

typedef struct _TStaticList
{
TDataNode* m_pHead;
TDataNode* m_pList;
}TStaticList;

int main(int argc, char* argv[])
{
int iNodeCount = 10; //自己修改

//创建并初始化链表及每个节点的信息
_TStaticList testList;
testList.m_pHead = (TDataNode*)malloc(sizeof(TDataNode));
testList.m_pList = (TDataNode*)malloc(iNodeCount*sizeof(TDataNode));

int i = 0;
for (;