目前共有1篇帖子。 內容轉換:不轉換▼
 
點擊 回復
196 0
【试题】振兴中华
一派護法 十九級
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

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
(快捷鍵:Ctrl+Enter)
 

本帖信息

點擊數:196 回複數:0
評論數: ?
作者:巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2016-3-19 11:11
 
©2010-2024 Arslanbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。