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

来源:互联网 发布:网页设计是美工吗 编辑:程序博客网 时间:2024/06/05 20:52
结构体:
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;}


0 0
原创粉丝点击