A - Word

Problem description

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
解题思路:题意很清楚,就是一个字符串中如果大写字母的个数小于或等于小写字母的个数,那么就全部换成小写字母;否则就全部换成大写字母,水过!
AC代码:
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main(){
 4     char s[105];int n1=0,n2=0;
 5     cin>>s;
 6     for(int i=0;s[i]!='\0';++i){
 7         if(s[i]>='A' && s[i]<='Z')n1++;
 8         else n2++;
 9     }
10     if(n1<=n2){
11         for(int i=0;s[i]!='\0';++i)
12             if(s[i]>='A' && s[i]<='Z')s[i]+=32;
13     }
14     else{
15         for(int i=0;s[i]!='\0';++i)
16             if(s[i]>='a' && s[i]<='z')s[i]-=32;
17     }
18     cout<<s<<endl;
19     return 0;
20 }

猜你喜欢

转载自www.cnblogs.com/acgoto/p/9162131.html