-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path59A_Word.cpp
More file actions
66 lines (58 loc) · 2.05 KB
/
Copy path59A_Word.cpp
File metadata and controls
66 lines (58 loc) · 2.05 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
A. Word
time limit per test2 seconds
memory limit per test256 megabytes
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word.That's why he decided to invent an extension
for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or,
vice versa, only of uppercase ones. At that as little as possible letters should be changed in the word. For example,
the word HoUse must be replaced with house, and the word ViP — with VIP. If a word contains an equal number of uppercase and lowercase letters,
you should replace all the letters with lowercase ones. For example, maTRIx should be replaced by matrix. Your task is to use the given method on one given word.
Input
The first line contains a word s — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100.
Output
Print the corrected word s. If the given word s has strictly more uppercase letters, make the word written in the uppercase register,
otherwise - in the lowercase one.
Examples
Input:
HoUse
Output:
house
Input:
ViP
Output:
VIP
Input:
maTRIx
Output:
matrix
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
using namespace std;
int main(){
int i,j,upp=0,low=0;
string s;
cin>>s;
int l = s.length();
for (i = 0; i < l; i++) {
if (s[i] >= 'A' && s[i] <= 'Z')
upp++;
else if (s[i] >= 'a' && s[i] <= 'z')
low++;
else
cout << "no";
}
if(upp<=low)
{
transform(s.begin(), s.end(), s.begin(), ::tolower);
cout<<s;
}
else if(upp>low)
{
transform(s.begin(), s.end(), s.begin(), ::toupper);
cout<<s;
}
else
return 0;
}