发布网友
共2个回答
热心网友
#include <stdio.h>
#include <stdlib.h>
typedef int data_t;
typedef struct _node_
{
int coef;
int index;
struct _node_ *next;
} linknode_t, *linklist_t;
linklist_t CreateLinklist()
{
linklist_t h;
h = (linklist_t)malloc(sizeof(linknode_t));
h->next = NULL;
return h;
}
int LengthLinklist(linklist_t h)
{
int len = 0;
h = h->next;
while (h != NULL)
{
len++;
h = h->next;
}
return len;
}
void VisitQuantic(linklist_t h)
{
h = h->next;
while (h != NULL)
{
printf(" %dX(%d)",h->coef, h->index);
h = h->next;
}
printf("\n");
return;
}
int InsertLinklist_1(linklist_t h, int coef, int index, int pos)
{
linklist_t p;
if ((pos < 0) || (pos > LengthLinklist(h))) return -1;
while (pos--) h = h->next;
p = (linklist_t)malloc(sizeof(linknode_t));
p->coef = coef;
p->index = index;
p->next = h->next;
h->next = p;
return 0;
}
#if 0
void InsertLinklist_2(linklist_t h, data_t x)
{
linklist_t p;
while ((h->next != NULL) && (h->next->data < x)) h = h->next;
p = (linklist_t)malloc(sizeof(linknode_t));
p->data = x;
p->next = h->next;
h->next = p;
}
#endif
void ClearLinklist(linklist_t h)
{
linklist_t p, q;
p = h->next;
h->next = NULL;
while (p != NULL)
{
q = p;
p = p->next;
free(q);
}
return;
}
void MergeQuantic(linklist_t ha, linklist_t hb) // code by yourself
{
}
int main()
{
int coef, index, pos;
linklist_t ha, hb;
ha = CreateLinklist();
hb = CreateLinklist();
printf("input for first quantic :\n");
pos = 0;
while ( 1 )
{
scanf("%d,%d", &coef, &index);
if (coef == 0) break;
InsertLinklist_1(ha, coef, index, pos++);
}
printf("input for second quantic :\n");
pos = 0;
while ( 1 )
{
scanf("%d,%d", &coef, &index);
if (coef == 0) break;
InsertLinklist_1(hb, coef, index, pos++);
}
VisitQuantic(ha);
VisitQuantic(hb);
return 0;
}追问你这玩意儿我复制到W3S根本没用!
热心网友
这问题简单得很,只是css+html,但是需要你有虚拟主机或服务器作支持。我个人资料里面有QQ,加我吧。