Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
WA了几次,将数组开得大了点就AC了将visit[26] char str[52]改为visit[30] char str[60]就AC了 #include "stdio.h" #include "string.h" int main() { int beds,tan,walk_away,visit[30]; int i,len,id; char str[60]; while(scanf("%d",&beds)&&beds) { scanf("%s",str); memset(visit,0,sizeof(visit)); tan=0; walk_away=0; len=strlen(str); for(i=0;i<len;i++) { id=str[i]-'A'; if(visit[id]==0) { if(tan<beds) { visit[id]=1; tan++; } else { visit[id]=2; walk_away++; } } else if(visit[id]==1) tan--; else if(visit[id]==2) continue; } if(!walk_away) printf("All customers tanned successfully.\n"); else printf("%d customer(s) walked away.\n",walk_away); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator