zoukankan      html  css  js  c++  java
  • A

    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]!='';++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]!='';++i)
    12             if(s[i]>='A' && s[i]<='Z')s[i]+=32;
    13     }
    14     else{
    15         for(int i=0;s[i]!='';++i)
    16             if(s[i]>='a' && s[i]<='z')s[i]-=32;
    17     }
    18     cout<<s<<endl;
    19     return 0;
    20 }
  • 相关阅读:
    bzoj 1232 [Usaco2008Nov]安慰奶牛cheer
    bzoj 1237 [SCOI2008]配对 贪心+dp
    缺8数
    缺8数
    Binary GCD algorithm
    Binary GCD algorithm
    HDU1576 A/B (解法二)【试探法】
    HDU1576 A/B (解法二)【试探法】
    I00002 打印九九乘法表
    I00002 打印九九乘法表
  • 原文地址:https://www.cnblogs.com/acgoto/p/9162131.html
Copyright © 2011-2022 走看看