1. 程式人生 > >【水輸入】#52 A. Bar

【水輸入】#52 A. Bar

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;
}