Skip to content

Commit 3d43ac7

Browse files
authored
Create Lecture - 18.cpp
1 parent 2783918 commit 3d43ac7

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

Lecture - 18.cpp

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

0 commit comments

Comments
 (0)