数据结构C语言版,两个题目求大神解答。

2025-05-01 06:02:18
推荐回答(1个)
回答1:

#define NULL 0

typedef struct node{
char data[50];
int length;
}seqstring;

void fun(seqstring* s) {
int i = 0, j = 0;
for (j = 0; j < s->length; j++) {
if (s->data[j] != '*') {
s->data[i] = s->data[j];
i++;
}
}
while (i < s->length) {
s->data[i] = '*';
i++;
}
}

typedef struct node {
int data;
struct node *lchild, *rchild;
}btnode;

int fun2(btnode* n, int level) {
if (n == NULL) return 0;
if (level == 0) return 1;
return fun2(n->lchild, level - 1) + fun2(n->rchild, level - 1);
}