错误太多了
#include <stdio.h>
#include <stdlib.h>
#define CardNumber 13
typedef struct node
{
int data;
struct node *next;
} sqlist, *linklist;
linklist CreateLinkList();
void Magician(linklist);
void DestoryList(linklist p);
int main(void)
{
//linklist p;
linklist p, q;
int i;
//p = CreateLinkList();
q = p = CreateLinkList();
Magician(p);
printf("按如下顺序排列:\n");
for (i = 0; i < CardNumber; i++)
{
//printf("黑桃%d", p->data);
printf("黑桃: %d, ", p->data);
p = p->next;
}
//DestoryList(p);
DestoryList(q);
return 0;
}
linklist CreateLinkList()
{
linklist head = NULL;
//linklist p = NULL;
//head->next = p;
//int i, n;
int i;
//n = CardNumber;
//for (i = 0; i < n; i++)
for (i = 0; i < CardNumber; i++)
{
linklist p = malloc(sizeof(*p));
p->data = 0;
p->next = head;
head = p;
//p = p->next;
}
//p->next = head;
return head;
}
void Magician(linklist p)
{
//int n, count, i;
int count, i;
p->data = 1;
count = 2;
// 下面这个循环看不懂
// 不知道你要做什么
/*
while (1)
{
for (i = 0; i < count; i++)
{
p = p->next;
if (p->data != 0)
{
p = p->next;
i--;
}
}
if (p->data == 0)
{
p->data = count;
count++;
}
if (count == 14)
{
break;
}
}
p = p->next;
*/
}
void DestoryList(linklist p)
{
//linklist temp = p;
linklist temp;
for (int j = 0; j < CardNumber; j++)
{
temp = p;
p = p->next;
free(temp);
}
}
|