Recursion 如何使用字符串数组作为递归的参数

Recursion 如何使用字符串数组作为递归的参数,recursion,c-strings,Recursion,C Strings,我正在为这个问题编写代码,却被困在一个地方: 问:我得到了一个二进制字符串,我应该对该字符串执行几个操作。在一个操作中,我可以选择一个仅包含0和1的非空偶数长度子字符串,并将其从字符串中删除 以下是我尝试过的: #include <math.h> #include <stdio.h> #include <string.h> void sub(char s[], int lens) { int count = 1, i = 1, top = 0, track

我正在为这个问题编写代码,却被困在一个地方:

问:我得到了一个二进制字符串,我应该对该字符串执行几个操作。在一个操作中,我可以选择一个仅包含0和1的非空偶数长度子字符串,并将其从字符串中删除

以下是我尝试过的:

#include <math.h>
#include <stdio.h>
#include <string.h>


void sub(char s[], int lens)
{
int count = 1, i = 1, top = 0, track = 0;
char a[lens];
a[0] = s[0];

while (i < lens) {
    
    if(s[i] != a[top] && count%2 == 0){
        a[top] = s[i];

        count = 1;

    }  
    else if(s[i] != a[top] && count%2 != 0){
        ++top;
        a[top] = s[i];

        count = 1;

    }
    else if(count >= 1 && s[i] == a[top]){
        count++;
        track ++;
        a[top] = s[i];
        
    }
i++;
}


if(track > 0)
    sub(a, top);
else{    

if(strlen(a) == 1 || strlen(a) == 0)
    printf("KHALI \n");
else if(strlen(a)%2 == 0){
    for(int j = 0; j < strlen(a); j++)
        printf("%c", a[j]);
    printf("\n");
    }
else {
    for(int j = 0; j < strlen(a)-1; j++)
        printf("%c", a[j]);
    printf("\n");
}
}

}



int main() {

int t;
//char *s = malloc(1000);
scanf("%d ", &t);

char s[t][100*t];
for(int i =0; i< t; i++)
{
    scanf("%s ", s[i]);
    //printf("%s \n", s[i]);
    char a[strlen(s)];
    sub(s[i], strlen(s[i]));
    memset(s, '\0', sizeof(s));
}

return 0;
}
我不能在这里使用
a
作为参数

if(track > 0)
    sub(a, top);