-
Notifications
You must be signed in to change notification settings - Fork 64
/
Lecture - 18.cpp
52 lines (51 loc) · 1.17 KB
/
Lecture - 18.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
using namespace std;
int main()
{
int T;cin>>T;
while(T--)
{
int n; cin>>n;
int k ; cin>>k;
string s; cin>>s;
int cap=0;
int small=0;
for(int i=0;i<n;i++)
{
char x = s[i];
int p = int(x); // ASCII CODE
// CAPITAL ASCII 65 to 90
// SMALL ASCII 97 to 122
if(p>=65 && p<=90)
cap++;
else
small++;
}
// we have no. of small and capital letters.
if(cap==small)
{
if(k>=cap)
cout<<"both"<<endl;
else if(k<cap)
cout<<"none"<<endl;
}
else if(small>cap)
{
if(k>=small)
cout<<"both"<<endl;
else if(k<cap)
cout<<"none"<<endl;
else
cout<<"chef"<<endl;
}
else if(cap>small)
{
if(k>=cap)
cout<<"both"<<endl;
else if(k<small)
cout<<"none"<<endl;
else
cout<<"brother"<<endl;
}
}
}