#2
书生牛犊2018-01-26 10:08
|
程序代码:
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "ctype.h"
typedef char Datatype;
typedef struct node{
struct node *tlink;
int tag;
union{
struct node *hlink;
Datatype value;
}info;
}Crossnode,*Crosslist;
#define maxsize 30
#define defaultsize 50
void createlist();
void createlist(char *s, int &i, Crossnode* &h, char L1[], Crosslist L2[], int &k)
{
Crossnode *p; char nam, ch;
nam = ch; ch = s[i++];
if (isupper(ch))
{
h = (Crossnode*)malloc(sizeof(Crossnode));
h->tag = 2; nam = ch; ch = s[i++];
if (ch == '(')
{
p = (Crossnode*)malloc(sizeof(Crossnode));
p->tag = 0;
h->info.hlink = p;
L1[k] = nam; L2[k++] = p;
if (s[i] == '#')
{
p->tlink = NULL;
i++;
}
createlist(s, i, p->tlink, L1, L2, k);
#include "stdlib.h"
#include "string.h"
#include "ctype.h"
typedef char Datatype;
typedef struct node{
struct node *tlink;
int tag;
union{
struct node *hlink;
Datatype value;
}info;
}Crossnode,*Crosslist;
#define maxsize 30
#define defaultsize 50
void createlist();
void createlist(char *s, int &i, Crossnode* &h, char L1[], Crosslist L2[], int &k)
{
Crossnode *p; char nam, ch;
nam = ch; ch = s[i++];
if (isupper(ch))
{
h = (Crossnode*)malloc(sizeof(Crossnode));
h->tag = 2; nam = ch; ch = s[i++];
if (ch == '(')
{
p = (Crossnode*)malloc(sizeof(Crossnode));
p->tag = 0;
h->info.hlink = p;
L1[k] = nam; L2[k++] = p;
if (s[i] == '#')
{
p->tlink = NULL;
i++;
}
createlist(s, i, p->tlink, L1, L2, k);