【水输入】#52 A. Bar

本文概述了AI音视频处理领域的关键技术,包括视频分割、语义识别、自动驾驶、AR、SLAM、物体检测与识别、语音识别变声等,为深入理解AI音视频处理提供全面视角。

A. Bar
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can check any person, i.e. learn his age and the drink he is having at the same time. What minimal number of people should Vasya check additionally to make sure that there are no clients under 18 having alcohol drinks?

The list of all alcohol drinks in Berland is: ABSINTHBEERBRANDYCHAMPAGNEGINRUMSAKE,TEQUILAVODKAWHISKEYWINE

Input

The first line contains an integer n (1 ≤ n ≤ 100) which is the number of the bar's clients. Then follown lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input data does not contain spaces and other unnecessary separators.

Only the drinks from the list given above should be considered alcohol.

Output

Print a single number which is the number of people Vasya should check to guarantee the law enforcement.

Sample test(s)
input
5
18
VODKA
COKE
19
17
output
2
Note

In the sample test the second and fifth clients should be checked.



题目需要我们数出数字为18以下的,以及和已有字符串相同的个数有多少个。(年龄小于18、喝的饮料为酒精饮料的个数)

混合输入处理,需要处理是数字还是字母的情况。

我们需要的函数为isupper() \ islower() \ isdigit()

这函数是通过ASCII码来判断某一个字符为大写字符、小写字符或数字的——

Code:


#include <cstdio>
#include <memory>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
string name[11]={"ABSINTH","BEER","BRANDY","CHAMPAGNE",
"GIN","RUM","SAKE","TEQUILA","VODKA","WHISKEY","WINE"};

int main()
{
	int n,cnt=0;	cin>>n;
	char huiche;	scanf("%c",&huiche);
	for(int i=0;i<n;i++)
	{
		string now;	cin>>now;
		//cout<<now<<endl;
		if(isupper(now[0]) || islower(now[0]))
		{
			for(int j=0;j<11;j++)
			{
				if(now==name[j])
				{
					cnt++;
					//cout<<cnt<<":"<<now<<endl;
					break;
				}
			}
		}
		else if(isdigit(now[0]))
		{
			int num=0;
			for(int j=0;j<now.length();j++) num=num*10+(now[j]-'0');
			if(num<18) 
			{
				cnt++;
				//cout<<cnt<<":"<<now<<endl;
			}
		}
	} 
	cout<<cnt<<endl;
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

糖果天王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值