『壹』 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個
見圖