当前位置: 首页> 健康> 母婴 > html网站设计实例代码_品牌形象设计的意义_公司产品推广文案_哪个平台可以接推广任务

html网站设计实例代码_品牌形象设计的意义_公司产品推广文案_哪个平台可以接推广任务

时间:2025/7/11 17:48:01来源:https://blog.csdn.net/qq_53989364/article/details/144357612 浏览次数:0次
html网站设计实例代码_品牌形象设计的意义_公司产品推广文案_哪个平台可以接推广任务

#define _CRT_SECURE_NO_WARNINGS 1
#include "SList.h"
TestSList()
{
    //SListNode* phead = NULL;
    SListNode* pList = NULL;//给一个初始结点
    SListPushBack(&pList, 1);
    SListPushBack(&pList, 2);
    SListPushBack(&pList, 3);
    SListPushBack(&pList, 4);
    SListPrint(pList);

    SListPopBack(&pList);
    SListPopBack(&pList);
    SListPopBack(&pList);
    SListPopBack(&pList);
    SListPopBack(&pList);
    SListPrint(pList);

    SListPushFront(&pList, 1);
    SListPushFront(&pList, 2);
    SListPushFront(&pList, 3);
    SListPushFront(&pList, 4);
    SListPushFront(&pList, 5);

    SListPrint(pList);

    SListPopFront(&pList);
    SListPopFront(&pList);
    SListPrint(pList);

    SListNode* pos = SListFind(pList, 2);
    if (pos)
    {
        pos->data = 20;
    }
    SListPrint(pList);

    SListInsertAfter(pos,8);
    SListPrint(pList);
    SListEraseAfter(pos);
    SListPrint(pList);
}

int main()
{
    TestSList();
    return 0;
}

#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef int SListDataType;
//创建一个结点
typedef struct SListNode
{
    //int data;
    SListDataType data;
    struct SListNode* next;//创建一个指针存下一个结点的地址
}SListNode;

//打印
void SListPrint(SListNode* phead);

//尾插尾删
void SListPushBack(SListNode** pphead, SListDataType x);
void SListPopBack(SListNode** pphead);

//头插头删
void SListPushFront(SListNode** pphead, SListDataType x);
void SListPopFront(SListNode** pphead);


//查找某一个数
//找到返回下标
SListNode* SListFind(SListNode* phead, SListDataType x);

//在指定位置后面插入,删除
void SListInsert(SListNode** pphead, SListDataType x);
void SListInsertAfter(SListNode* pos);
 

#define _CRT_SECURE_NO_WARNINGS 1
#include "SList.h"
void SListPrint(SListNode* phead)
{
    SListNode* cur = phead;
    while (cur != NULL)
    {
        printf("%d->", cur->data);
        cur = cur->next;//找到下一个结点的地址
    }
    printf("NULL\n");
}

SListNode* BuySListNode(SListDataType x)
{
    //创建一个新结点
    SListNode* newNode = (SListNode*)malloc(sizeof(SListNode));
    //判断申请结点是否成功
    if (newNode == NULL)
    {
        printf("申请结点失败\n");
        exit(-1);
    }
    newNode->data = x;
    newNode->next = NULL;
    return newNode;
}


void SListPushBack(SListNode** pphead, SListDataType x)
{
    SListNode* newNode = BuySListNode(x);
    if (*pphead == NULL)
    {
        //将值存进去
        *pphead = newNode;
    }
    else
    {
        SListNode* tail = *pphead;
        //先找到尾
        //SListNode* tail = *pphead;
        while (tail->next != NULL)
        {
            tail = tail->next;
        }
        tail->next = newNode;
    }
}

void SListPopBack(SListNode** pphead)
{
    //1.0个结点
    //2.1个结点
    //3.多个结点
    if (*pphead == NULL)
    {
        return;
    }
    else if ((*pphead)->next==NULL)
    {
        free(*pphead);
        *pphead = NULL;
    }
    else
    {
        SListNode* prev = NULL;
        SListNode* tail = *pphead;
        //先找到尾
        //SListNode* tail = *pphead;
        while (tail->next != NULL)
        {
            prev = tail;
            tail = tail->next;
        }
        free(tail);//tail是局部变量,所以不用置为空
        prev->next = NULL;
    }
}


void SListPushFront(SListNode** pphead, SListDataType x)
{
    SListNode* newNode = (SListNode*)malloc(sizeof(SListNode));
    SListNode* next = *pphead;
    newNode->data = x;
    *pphead = newNode;
    newNode->next = next;
}


void SListPopFront(SListNode** pphead)
{
    //1.空
    //2.一个结点 + 3.一个以上结点
    if (*pphead == NULL)
    {
        return;
    }
    else
    {
        SListNode* next = (*pphead)->next;
        free(*pphead);
        (*pphead) = next;
    }
}


SListNode* SListFind(SListNode* phead, SListDataType x)
{
    SListNode* cur = phead;
    while (cur != NULL)
    {
        if (cur->data == x)
        {
            return cur;
        }
        cur = cur->next;
    }
    //找不到
    return NULL;
}


void SListInsertAfter( SListNode* pos, SListDataType x)
{
    assert(pos);
    SListNode* newNode = BuySListNode(x);
    newNode->next = pos->next;
    pos->next = newNode;
}

void SListEraseAfter(SListNode* pos)
{
    assert(pos);
    if (pos)
    {
        SListNode* next = pos->next;
        SListNode* nextnext = next->next;
        pos->next = nextnext;
        free(next);
    }
}

关键字:html网站设计实例代码_品牌形象设计的意义_公司产品推广文案_哪个平台可以接推广任务

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: