#9815: 求解惑~想破頭還是想不出來~~


B0306125 (Rekkursion)

學校 : 臺北市立大安高級工業職業學校
編號 : 47515
來源 : [140.112.238.177]
最後登入時間 :
2024-11-07 22:06:51
d217. 00489 - Hangman Judge -- UVa489 | From: [111.184.39.89] | 發表日期 : 2015-04-24 21:57

 我的程式碼:

#include <stdio.h>

#include <string.h>

int main()

{

int n , k , j , t , qlen , alen , death , judge , book[123];

char q[200] , a[200];

while(1)

{

judge = 0;

for(k = 0 ; k < 123 ; k++)

{

book[k] = 0;

}

scanf("%d" , &n);

if(n == -1)

{

break;

}

scanf("%s%s" , &q , &a);

qlen = strlen(q);

alen = strlen(a);

death = 0;

for(k = 0 ; k < strlen(a) ; k++)

{

for(j = 0 , t = 0 ; j < strlen(q) ; j++)

{

if(a[k] == q[j])

{

t++;

q[j] = '0';

}

}

alen--;

qlen = qlen - t;

if(t == 0 && book[a[k]] == 0)

{

death++;

book[a[k]] = 1;

}

if(death == 7)

{

judge = 3;

break;

}

if(qlen == 0)

{

judge = 1;

break;

}

if(alen == 0 && qlen != 0 && death != 7)

{

judge = 2;

break;

}

}

printf("Round %d\n" , n);

if(judge == 1)

{

printf("You win.\n");

}

if(judge == 2)

{

printf("You chickened out.\n");

}

if(judge == 3)

{

printf("You lose.\n");

}

}

return 0;

}

 

第 1 測資點(0%): WA (line:78) 
答案不正確

您的答案為: You lose. 正確答案為: You chickened out.
 能幫忙的話真的很感謝~謝謝~~ 
 
ZeroJudge Forum