目前共有1篇帖子。
【试题】振兴中华
1樓 巨大八爪鱼 2016-3-19 11:11
#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

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
 
 
©2010-2025 Arslanbar [手機版] [桌面版]
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。