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.
Sample Input
HoUse
house
ViP
VIP
maTRIx
matrix
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a[110];
int main(){
int len,x,y;
x=0;
y=0;
gets(a);
len=strlen(a);
for(int i=0;i<len;i++){
if(a[i]>=97){
x++;
}
else{
y++;
}
}
if(x<y){
printf("%s\n",strupr(a));//字符串转大写
}
else{
printf("%s\n",strlwr(a));//字符串转小写
}
return 0;
}
本文介绍了一种用于浏览器的扩展方法,旨在自动调整文本中的字母大小写,使其全部为大写或小写,同时尽量减少修改的字母数量。通过分析给定单词的字母分布,该方法能高效地实现文本格式的统一,简化阅读体验。
670

被折叠的 条评论
为什么被折叠?



