[ACM ] 11035 Card Hands (Runtime Error...)
( *[1m *[m 為色碼,可以按 Ctrl+V 預覽會顯示的顏色 )
( 未必需要依照此格式,文章條理清楚即可 )
題號:11035
http://icpcres.ecs.baylor.edu/onlinejudge/external/110/11035.html
遇到的問題:Runtime Error
有問題的code:
#include<stdio.h>
int change(char t[])
{
if (t[0]=='1' && t[1]=='0')
{
t[1]=t[2];
return 10;
}
else if(t[0]=='A')
return 1;
else if(t[0]=='J')
return 11;
else if(t[0]=='Q')
return 12;
else if(t[0]=='K')
return 13;
else if(t[0]>48 && t[0]<58)
return t[0]-48;
else
return 0;
}
int reindex(char temp[])
{
int a=change(temp);
if(a==0)
return 0;
if(temp[1]=='S')
return a;
if(temp[1]=='C')
return a+13;
if(temp[1]=='D')
return a+26;
if(temp[1]=='H')
return a+39;
else
return 0;
}
void main()
{
char temp[3];
int c,h,i=1,j,a;
int arr1[53]={0};
fflush(stdin);
scanf("%d",&c);
while(1)
{
if(c<0)
break;
scanf("%d",&h);
if(h<1)
break;
for(j=1;j<=h;j++)
{
scanf("%s",temp);
if(i<=c)
{
a=reindex(temp);
if(arr1[a]==0)
arr1[a]=1;
}
}
++i;
}
j=0;
for(i=1;i<=52;i++)
if(arr1[i]!=0)
j++;
printf("%d\n",j);
}
補充說明:難以理解的Runtime Error ,懇請板上高手解救~~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.50.29
→
03/25 06:44, , 1F
03/25 06:44, 1F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章