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 }
  • 相关阅读:
    Unity StrangeIoc框架 (三)signal信号方式
    Unity StrangeIoc框架 (二)
    Unity StrangeIoc框架 (一)
    Android应用如何监听自己是否被卸载及卸载反馈功能的实现(第三版)
    2017年50道Java线程面试题
    常见Android面试题及答案(详细整理)
    Android 高级面试题及答案
    Android 面试精华题目总结
    android面试题总结加强再加强版(一)
    2017 Android 面试题 [ 基础与细节 ]
  • 原文地址:https://www.cnblogs.com/acgoto/p/9162131.html
Copyright © 2011-2022 走看看