C언어 배우고 있는사람인데.. 컴파일에러가 왜나는지 모르겠어요..

  • previc
    previc

    scanf에서 unsigned int받는부분이랑
    float *p = Cache; 부분에서 타입이 안맞다고 에러나오는것같은데..
    뭐가잘못된건지 좀 알려주세요..
    C언어 독학으로 배운지 얼마안되서 진짜 쌩초보입니다 ㅠㅠ

    #include <stdio.h>
    float Cache[2001][1001];
    unsigned int n;
    float escape(int depth, int day) {
        float *ret = &Cache[depth][day];
        if (day == 0)
        {
            return *ret = depth >= n ? 1 : 0;
        }
        else
        {
            if (*ret != -1)
            {
                return *ret;
            }
            else
            {
                return *ret = 0.25*escape(depth + 1, day - 1) + 0.75*escape(depth + 2, day - 1);
            }
        }
    }
    
    int main() {
        unsigned int C;
        scanf("%d", &C);
        while (C)
        {
            float *p = Cache;
            float *q = p + 2001*1001-7;
            for (p = Cache; p < q; p += 8)
            {
                *(p) = *(p + 1) = *(p + 2) = *(p + 3) = *(p + 4) = *(p + 5) = *(p + 6) = *(p + 7) = -1;
            }
    
            scanf("%d", &n);
            unsigned int m;
            scanf("%d", &m);
            printf("%.10f\n", escape(0, m));
            --C;
        }
        return 0;
    }
    

    7년 전
2개의 댓글이 있습니다.
  • windless
    windless

    다음과 같이 해보세요:

    • float *p = Cache[0];
    • scanf("%u", &C);

    7년 전 link
  • previc
    previc

    감사합니다.. 잘되네요ㅠㅠ


    7년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.