#include <stdio.h>
#include <string.h>
char *str[] = {"从我做起振", "我做起振兴", "做起振兴中", "起振兴中华"};
char buffer[30];
int cnt = 0;
void search(char *pStr, int x = 0, int y = 0)
{
*pStr = str[y][x * 2];
*(pStr + 1) = str[y][x * 2 + 1];
if (x < 4)
search(pStr + 2, x + 1, y);
if (y < 3)
search(pStr + 2, x, y + 1);
if (x == 4 && y == 3)
{
*(pStr + 2) = '\0';
if (strcmp(buffer, "从我做起振兴中华") == 0)
cnt++;
}
}
int main(void)
{
search(buffer);
printf("%d\n", cnt);
return 0;
}
答案:35