zp1405.cpp
来自「浙江大学acm在线判题器代码集。 本人在浙大acm判题器上的所有代码(心血) 」· C++ 代码 · 共 39 行
CPP
39 行
#include <stdio.h>
int main(int argc, char* argv[])
{
int n,i,m,s,p[26];
char st[100];
while (scanf("%d",&n) && n)
{
for (i=0;i<26;i++)
p[i]=0;
scanf("%s",st);
s=0; m=0;
for (i=0;st[i]!='\0';i++)
{
if (p[st[i]-'A']==0)
{
s++;
p[st[i]-'A']=1;
if (s>n)
{
s--;
m++;
p[st[i]-'A']=-1;
}
}
else
if (p[st[i]-'A']==1)
s--;
}
if (m)
printf("%d customer(s) walked away.\n",m);
else
printf("All customers tanned successfully.\n");
}
return 0;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?