已知一单链表中的数据元素含有三类字符:字母、数字和其他字符。是编写算法,构造三个循环链表,使每个循环链表中只含同一类字符

结构体:

struct NodeInt{
    int num;
    struct NodeInt * next;
};

struct NodeChar{
    char character;
    struct NodeChar * next;
};

struct NodeDouble{
    double dou;
    struct NodeDouble * next;
};

template <class T,class N>
N * create(T * array,int n)
{
    N *p , *head , *q;
    head = (N*)malloc(sizeof(N));
    p = head;
    int i = 1;
    if( 0 != n )
    {
        while( i <= n )
        {
            q = (H*)malloc(sizeof(H));
            q->a = array[i - 1];
            p->next = q;
            p = q;
            i++;
        }
        q->next = head->next;
    }
    free(head);
    return q->next;
}
    原文作者:dancheng_work
    原文地址: https://blog.csdn.net/dancheng1/article/details/52847015
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞