Time Limit: | Memory Limit: | 64bit IO Format: |
Description
Vasya is very upset that many people on the Net mix uppercaseand lowercase letters in one word. That's why he decided to inventan extension for his favorite browser that would change theletters' register in every word so that it either only consisted oflowercase letters or, vice versa, only of uppercase ones. At thatas little as possible letters should be changed in the word. Forexample, theword
Input
The first line contains a word
Output
Print the corrected word
Sample Input
HoUse
house
ViP
VIP
maTRIx
matrix
#include<iostream> using namespace std; int main() { char str[105]; int i,j; int count1,count2; while(gets(str)) { for(i=0;i<strlen(str);i++) { if(str[i]>='A'&&str[i]<='Z') count1++; else count2++; } if(count2>=count1) for(j=0;j<strlen(str);j++) { if(str[j]>='A'&&str[j]<='Z') str[j]=str[j]+32; } else for(j=0;j<strlen(str);j++) { if(str[j]>='a'&&str[j]<='z') str[j]=str[j]-32; } for(j=0;j<strlen(str);j++) cout<<str[j]; cout<<endl; } return 0; }