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: ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE,TEQUILA, VODKA, WHISKEY, WINE
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.
Print a single number which is the number of people Vasya should check to guarantee the law enforcement.
5 18 VODKA COKE 19 17
2
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;
}
本文概述了AI音视频处理领域的关键技术,包括视频分割、语义识别、自动驾驶、AR、SLAM、物体检测与识别、语音识别变声等,为深入理解AI音视频处理提供全面视角。

359

被折叠的 条评论
为什么被折叠?



