‘壹’ sql怎么把一个单链表分解成两个单链表
程序如下:
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
char data;
struct node *nextPtr;
}*LinkList, Lnode;
static void CreateList(LinkList *headPtr, LinkList *tailPtr, char ch);
static void Decompose(LinkList *headPtrA, LinkList *headPtrB, LinkList *tailPtrB);
static void VisitList(LinkList headPtr);
static void DestroyList(LinkList *headPtr, LinkList *tailPtr);
int main(void)
{
LinkList headPtrA = NULL, tailPtrA = NULL, headPtrB = NULL, tailPtrB = NULL;
char ch;
while (1)
{
printf("Enter ch('@'-quit): ");
scanf(" %c", &ch);
if (ch == '@')
{
break;
}
else
{
CreateList(&headPtrA, &tailPtrA, ch);
}
}
VisitList(headPtrA); /* 打印分解前的链表 */
if (headPtrA != NULL) /* 链表不空的情况对其进行分解 */
{
Decompose(&headPtrA, &headPtrB, &tailPtrB); /* 对链表进行分解*/
}
else
{
printf("headPtrA is empty. ");
}
VisitList(headPtrA); /* 打印分解后的链表 */
VisitList(headPtrB);
DestroyList(&headPtrA, &tailPtrA); /* 销毁链表 */
DestroyList(&headPtrB, &tailPtrB);
return 0;
}
static void CreateList(LinkList *headPtr, LinkList *tailPtr, char ch)
{
LinkList newPtr;
if ((newPtr = (LinkList)malloc(sizeof(Lnode))) == NULL)
{
exit(1);
}
newPtr -> data = ch;
newPtr -> nextPtr = NULL;
if (*headPtr == NULL)
{
newPtr -> nextPtr = *headPtr;
*headPtr = newPtr;
}
else
{
(*tailPtr) -> nextPtr = newPtr;
}
*tailPtr = newPtr;
}
static void Decompose(LinkList *headPtrA, LinkList *headPtrB, LinkList *tailPtrB)
{
int count = 0;
LinkList cA, pA;
char ch;
cA = NULL;
for (pA = *headPtrA; pA != NULL; cA = pA,pA = pA -> nextPtr)
{
ch = pA -> data;
count++;
if (count % 2 == 0)
{
CreateList(headPtrB, tailPtrB, ch);
cA -> nextPtr = pA -> nextPtr;
}
}
}
static void VisitList(LinkList headPtr)
{
while (headPtr != NULL)
{
printf("%c -> ", headPtr -> data);
headPtr = headPtr -> nextPtr;
}
printf("NULL ");
}
static void DestroyList(LinkList *headPtr, LinkList *tailPtr)
{
LinkList tempPtr;
while (*headPtr != NULL)
{
tempPtr = *headPtr;
*headPtr = (*headPtr) -> nextPtr;
free(tempPtr);
}
*headPtr = NULL;
*tailPtr = NULL;
}
‘贰’ 求助SQL语句,要把一张表拆成2张表!
销售主表
select distinct 单据号,单据日期,客户名称,备注 from 销售表
销售子表
select 单据号,商品名称,规格型号,数量,单价,金额 from 销售表 order by 单据号
SID,FID从哪里来的?
‘叁’ 怎么把SQL中的一个表分成2个表。并且这两个表有自己的名字
select*into学生1from学生表where学院='学院名称1'
select*into学生2from学生表where学院='学院名称2'
‘肆’ 请问怎么把sql里的表格的内容拆成2个
见图