2 shunfurh shunfurh 于 2017.09.14 21:24 提问

Tanning Salon

Tan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if a customer arrives and there are no beds available, the customer will turn around and leave, thus costing the company a sale. Your task is to write a program that tells the company how many customers left without tanning.
The input consists of data for one or more salons, followed by a line containing the number 0 that signals the end of the input. Data for each salon is a single line containing a positive integer, representing the number of tanning beds in the salon, followed by a space, followed by a sequence of uppercase letters. Letters in the sequence occur in pairs. The first occurrence indicates the arrival of a customer, the second indicates the departure of that same customer. No letter will occur in more than one pair. Customers who leave without tanning always depart before customers who are currently tanning. There are at most 20 beds per salon.

For each salon, output a sentence telling how many customers, if any, walked away. Use the exact format shown below.

Sample Input

2 ABBAJJKZKZ
3 GACCBDDBAGEE
3 GACCBGDDBAEE
1 ABCBCA
0

Sample Output

All customers tanned successfully.
1 customer(s) walked away.
All customers tanned successfully.
2 customer(s) walked away.

1个回答

shen_wei
shen_wei   Ds   Rxr 2017.09.15 16:55
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
POJ 1250 Tanning Salon(我的水题之路——字母表数组标记)
Tanning Salon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5475   Accepted: 2994 Description Tan Your Hide, Inc., owns several coin-operated tanning sal
POJ1250:Tanning Salon
Description Tan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if a customer arrives and there are no beds available, the customer will turn around and leave, thu
【队列】poj1250 Tanning Salon
传送门:http://poj.org/problem?id=1250
Tanning Salon
Tanning Salon 时间限制(普通/Java):3000MS/10000MS          运行内存限制:65536KByte 总提交:25            测试通过:17 描述 Tan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if
ZOJ 1405 Tanning Salon
<br />#include <stdio.h> #include <string.h> #define EMPTY '2' char bed[25]; char a[2000]; int k,j; int i,n; char c; char bad_luck[200]; int leave() { for (i=0;i<n;i++) if (a[k] == bed[i]) { bed[i] = EMPTY; r
难题Tanning Salon
这是一道关于客人进出问题的题,要我觉得也是一道“开关”类型的题目,这道题反正对我这个初学者来说比较难,这道题的大体意思是:一横数据包括两部分,一个数字n(就好像是床的数目), 后边是来的客人(用大写字母表示),字母第一次出现表示客人进来,第二次出现表示离开,一次类推,计算流失的客人数目。 刚开始做的时候一点思路都没有,题目的意思到不难,后来还好提交时候虽然错了好几次,但是,我的思路是正确的,这是我
poj 1250(Tanning Salon)
题意:一个旅馆有n个位,给出所有旅客到达旅馆和离开旅馆的顺序,问有多少旅客是没有住旅馆就离开的。 由于题目中告诉每个顾客只会出现一次,所以我用一个数组存储每个顾客的情况直接模拟: Tanning Salon Time Limit: 1000MS   Me
poj1250 Tanning Salon
#include #include void main(){ int n; char s[53],c[26]; int i,l,count,leave; scanf("%d",&n); while(n != 0 && n<=20){ memset(s,'\0',sizeof(s)); memset(c,'0',sizeof(c)); scanf("%s",s); l=s
1250 Tanning Salon
Description Tan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if a customer arrives and there are no beds available, the customer will turn around and leave, t
POJ - 1250 Tanning Salon
解题思路:水题,与栈有点像