Description
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
Input
The first line contains an integer n (1 ≤ n ≤ 100) which is the number of the bar's clients. Then follow n 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 Input
5 18 VODKA COKE 19 17
2
Hint
In the sample test the second and fifth clients should be checked.
题意:判断不满18岁并且喝酒的有多少人,题上有两种输入,一种是确定喝的是酒,给出了该人年龄,一种是确定为不满18岁,给出了喝的饮料的名字。
思路:直接看代码吧
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
char s[][110]={"ABSINTH","BEER","BRANDY","CHAMPAGNE","GIN","RUM","SAKE","TEQUILA","VODKA","WHISKEY","WINE"};
int t,n,i,j;
char str[110];
while(scanf("%d",&n)!=EOF)
{
int count=0;
for(i=0;i<n;i++)
{
scanf("%s",str);
int len=strlen(str);
if(len==1&&str[0]-'0'>=0&&str[0]-'0'<=9)
{
count++;
continue;
}
if(len==2&&str[0]-'0'==1&&(str[1]-'0'>=0&&str[1]-'0'<8))
{
count++;
continue;
}
for(j=0;j<11;j++)
{
if(strcmp(str,s[j])==0)
{
count++;
break;
}
}
}
printf("%d\n",count);
}
return 0;
}