p1405.cpp
来自「高手写的所有acm例程 在acm.zju.edu.cn 上的题目的例程」· C++ 代码 · 共 41 行
CPP
41 行
// zju 1405
#include <iostream>
#include <fstream>
using namespace std;
//ifstream in ( "p.in" );
//ofstream out ( "p.out" );
istream &in = cin;
ostream &out = cout;
int Limit;
char Data [255];
bool Leave [255];
int len;
main ()
{
int i , have , Ans;
while ( in >> Limit , Limit ) {
in >> Data;
len = strlen ( Data );
memset ( Leave , 0 , sizeof ( Leave ));
for ( Ans = i = have = 0; i < len; i ++ ) {
if ( !Leave [Data [i]] ) {
Leave [Data [i]] = 1;
have ++;
if ( have > Limit ) Ans ++;
} else {
Leave [Data [i]] = 0;
have --;
}
}
if ( Ans ) out << Ans << " customer(s) walked away.\n";
else out << "All customers tanned successfully.\n";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?